On almost every topic

David Webster wrote a post about some improvements of Alfresco Share’s Calendar and what I liked most about it is that his improvements introduced the jQuery library in Alfresco.

I have been using jQuery for some time mainly to create Alfresco dashlets and I know that many other developers are using jQuery to do customizations in Alfresco, so I am very happy that the library will be part of the Alfresco Share distribution soon.

Thanks to David in the near future we do not have to feel guilty any more for bypassing YUI in favour of jQuery. 

Alfresco Is Being Refactored

Last week I attended the Alfresco Developer Conference in Paris and one of the things I realized during the conference was how many core parts of Alfresco are currently being refactored.

Persistency Layer
One major change is that they replaced the Hibernate persistency layer with iBATIS. This layer is responsible for writing objects to the database, performing database queries and reading objects from the database. Some parts of Alfresco already used iBATIS, but starting with version 3.4 Hibernate is completely removed in favor of iBATIS. According to Alfresco the new persisteny layer provides more control resulting in an improved performance, scalability and stability.

Domain Model
They also moved the code for the domain model from the repository project to a separate project in the code repository. The new project is called data-model. The main reason for this is to prepare the replacement of Lucene with Solr, an enterprise search platform based on Lucene. Solr provides a better separation of concerns and has a lot of features that are not available in Lucene. Solr provides features like clustering and replication, hit highlighting and faceted search. I expect the integration of Solr to be a major improvement. As far as I know it is not yet on the road map, so it is unclear when it will be released. I expect Alfresco to use a more loosely coupled approach here. In the future this might even make it possible to configure Alfresco to use a different search engine.

Workflow
Although starting with version 3.4 Alfresco Share supports the advanced worklfow capabilities based on the current workflow engine, this is likely to change in the near future. A team of Alfresco developers is currently developing a complete new BPM and workflow system called Activiti. The presentations at the conference looked very promising. Activiti is based on the general purpose process language BPMN 2.0 and attempts to bring together developers and business people. It fits into any Java based application, but also provides web based clients to directly support end users.

Web Content Management
Another big project is the replacement of the WCM (Web Content Management) module. Currently WCM support is only available in the Alfresco Explorer interface and under the hood it uses a repository implementation that is not compatible with the regular content repository. A couple of sessions at the conference discussed new core services that will be used by a new WCM module that is currently under development. These include the Transfer Service and the Rendition Service, but there are also major changes in the Action Service.

Web Quick Start
To demonstrate the new capabilities, the Alfresco team created a Web Quick Start application that you can use to create a dynamic web site with Alfresco Share as content management backend. I was suprised by the amount of features they put into the application. It is highly configurable and includes a reusable domain model, support for content renditions, deployments to test and live servers and even content caching. The frontend is build using Spring Surf, CMIS and Web Scripts.

At the same time the quick start application reveales how much there is to be done. It is currently not possible to deploy static content to a web server, there is no support for custom content types or XML content editing, there is no such thing as a Web Project or Web Project Site and there is no overall lifcycle in place to create, approve, publish, expire and monitor web content.

Alfresco Share
Of course Alfresco Share itself is also an ongoing project with a major impact. With every release new features are added to improve the collaboration capabilities and to provide general content management features currently only available in Alfresco Explorer. It will take a while before Alfresco Share completely replaces Alfresco Explorer, but today Share provides a serious alternative to Microsoft Sharepoint. Alfresco is also constantly improving the configuration options for Alfresco Share to make it more simple to tailor the system to customer needs.

Although Share is a major improvement for end users compared to Alfresco Explorer, I am still not fully convinced that Alfresco made the right decision to build a client using the Yahoo User Interface (YUI). For developers the learning curve is very steep and I am not sure if the library is future proof. I guess if someday Alfresco wanted to move to a newer version of YUI, they have to rebuild most of the client interface since for version 3 the developers at Yahoo decided to completely rebuild the library.

I can only agree with Jeff Potts. Alfresco Share has a nice interface, there are a lot of great features, but it seems to be a product rather than a platform that you can easily customize. Alfresco improved the way you can package new modules, but the product itself is not build using a modular approach. At the same time the Surf platform that is used to build Share is too bare bones to build content centric Alfresco clients.

In addition we experience that for a lot of developers the YUI (Yahoo User Interface) library that is used to build the Share interface has a steep learning curve compared to other AJAX/RIA frameworks like for example JQuery or Ext JS

Jeff Potts about this interesting new feature in Alfresco Share Community 3.3.

Google Docs integration with Alfresco.

This integration looks promising. It removes the need to download documents to the desktop or use the MS Office tools. Users can check out documents from Alfresco Share to Google Docs, edit the document in Google Docs and then check in the revised copy to Alfresco. I assume it requires a Google account. I guess in the end users would like to edit MS Office documents directly from within Alfresco Share. At the Alfresco meetups last year it was announced that a third party is developing this feature.

There are interesting features in the new Alfresco Community release including CMIS 1.0 support, content repurposing, improved repository replication and content deployment services and content rules in Alfresco Share. Integration with Google Docs will be available next month. This will be a first step towards providing online editing capabilities for office documents.

Spring Surf with an Alfresco backend

Spring Surf is actively under development. Recently authentication against Alfresco was added to the Surf Quick Start application making it very simple to add an Alfresco backend to your Surf application. To get an idea in what direction this is heading to, I added a page to the example application that displays blog posts from Alfresco Share. The page requires authentication.

Note: this tutorial demonstrates Spring Surf features that are not stable yet.

Environment

I have an Alfresco Enterprise 3.2r backend running on http://localhost:8080/alfresco and will run Jetty on my Surf project. I guess it will also work with Alfresco Community. Make sure that you have Maven installed.

Download Spring Roo

The first step is to download and install Spring Roo from the Spring Source Community download page at http://www.springsource.com/download/community. Spring Roo is a rapid application development tool for Java developers focusing on productivity and ease of use.

The next step is to download the latest snapshot for the Spring Surf Roo Addon from http://www.springsurf.org/downloads.html. Of course you can also create a new build. Check the Spring Source Development Guide for instructions on how to do this. In order to build from source you need a Subversion client and Maven. Add the snapshot for Roo to the dist directory of your Roo installation (on my Windows machine it is C:\Apps\spring-roo-1.0.2.RELEASE\dist). It might be useful to open the Surf Roo Command Index as a reference.

Create a project

We are now ready to create a new project with Roo. From the command line navigate to a directory where you want to create your application, create a new directory for your Surf application and start the Roo shell:

c:\projects>mkdir surf-alfresco

c:\projects>cd surf-alfresco

c:\projects\surf-alfresco>roo

Your Roo shell looks similar to this:

We are now ready to start coding. First create a new project:

roo>project --topLevelPackage com.example.surf

Tip: roo supports completion using the TAB key, so if you type project and then TAB roo will suggest to add the topLevelPackage argument.

Now install Surf:

roo>surf install

When you install Surf, Roo creates an example application to get you started. We will add authentication to this application and a new page showing blog posts from an Alfresco Share site called Company.

Enable authentication

In order to to enable authentication against the Alfresco repository, open the file surf.xml in the src/main/webapp/WEB-INF directory and comment out the following line:

<user-factory>webframework.factory.user.alfresco32</user-factory>

In addition I made some changes to the file login.ftl in the src/main/webapp/WEB-INF/templates/sample directory. I changed these lines:

<input name="success" type="hidden" value="/"/>
<input name="failure" type="hidden" value="/type/login"/>

To:

<input name="success" type="hidden" 
  value="${url.context}/sample/userinfo"/>
<input name="failure" type="hidden" 
  value="${url.context}/sample/login"/>

This will show the user information on a successful login and the login page when the login is not successful. The templates for login, logout and the user information are already added as example templates.

Test the application

You can now test the application. To do this exit roo and run Jetty:

roo>exit
c:\apps\surf-allfresco>mvn jetty:run

Make sure Alfresco is also running and visit the Surf application by visiting http://localhost:8180/

You should see the following page. This is the example application we created by installing Surf:

Now visit the page http://localhost:8180/sample/login. You should see a page like this:

Type an Alfresco user name and password en click Log In. The system should now display the login details.

You are now able to authenticate, so the next step is to add a page that requires the user to login. To stop Jetty you can simple type Ctrl-C.

Note: you are not required to stop Jetty, you can also open a new command shell. Jetty will notice changes and do a reload.

Create a new component

We start with creating a new Surf component. Surf components basically are Web Scripts. If you are not familiar with Web Scripts, you might want to read some documentation first. You can find it here.

First we create a folder called posts under the WEB-INF/webscripts directory. We then create a new file called posts.get.desc.xml with the following content:

<webscript>
  <shortname>Company Posts</shortname>
  <description>Company Posts</description>
  <url>/news/posts</url>
  <authentication>user</authentication>
</webscript>

This is the descriptor for our new component. It provides a name and description and a URL to provide access to the resource. We also set the authentication to user, since we require the user to be authenticated when he/she requests blog posts. By default authentication is set to none.

The next step is to create the controller. The controller knows what to do when the user requests the resource (in this case showing the blog posts stored in Alfresco). The controller is implemented using JavaScript. Create a file called posts.get.js with the following contents:

var connector = remote.connect("alfresco");
var result = connector.get("/api/blog/site/company/blog/posts");
logger.log(result);
var posts = eval('(' + result + ')');
model.posts = posts;

The connector’s get method retrieves the blog posts from a site called company. You can change company with the name of any Alfresco Share site. If you do not have a site yet, you can create one and add some blog posts to it.

The final part of the component is the view. The Web Scripts Framework uses Freemarker as the default template engine. Create a file called posts.get.html.ftl and add the following contents:

<div>
<#if posts.items?exists>
  <#list posts.items as post>
    <h2>${post.title}</h2>
    ${post.content}
  </#list>
<#else>
There are no posts.
</#if>
</div>

I must admit that this template is not going to return a stunning web page, but for now it will work just fine.

One final change I made is to forward the user to the news page on a succesful login in stead of the user information by editing the login.ftl once more:

<input name="success" type="hidden" value="${url.context}/news" />

Create a new page

We now have to revisit Roo to create a new page, add the required components to the page including our blog posts component and to add the page to the site navigation. To do this start Roo and first create the page:

roo> surf page create --id news --template home

We create a new page based on the existing template for the Home Page. Next we add the blog posts to the main region of the page:

roo> surf component create --page news --region main
  --url /news/posts

We can then run a report to see if we need to add addditional components:

roo> surf report page --id news
-----------------------------------------------------------
Report on Page news

-----------------------------------------------------------
Basic Information

Id: news
Name: news
Path: pages\news\news.xml
Instance: home
Template: home
-----------------------------------------------------------
Page Scoped Components

Region: main Url: /news/posts
Region: side Scope: page Configued: false

-----------------------------------------------------------
Template Scoped Components

Region: header Url: /company/header
Region: horznav Url: /navigation/horizontal
Region: footer Url: /company/footer

-----------------------------------------------------------
Global Scoped Components

-----------------------------------------------------------
Page Associations

-----------------------------------------------------------

It seems that the component for the side region is missing, so we simply add the same component as the one used for the home page. I simply looked it up in the file pages/home/home.xml and it is the component /home/side:

roo> surf component create --page news --region side 
  --url /home/side

The last thing we need to do is to add our new page to the horizontal navigation by creating an association between the page home and our new page called news:

code>roo> surf page association create --sourceId home 
  --destId news

We can now exit Roo:

roo>exit

Before starting Jetty again, visit the page news.xml and set authentication to user instead of none. Save the file and run Jetty again.

c:\projects\surf-alfresco>mvn jetty:run

Test the new page

Now test the application by visiting http://localhost:8180 again. You should see a news button added to the horizontal navigation:

When you click the news page, the system shows the login page again and returns to the news page on a successful login:

We now have added a page to Surf’s Quick Start application that enables the user to authenticate against Alfresco and read blog posts stored in the backend repository.

Conclusion

Spring Surf and Spring Roo provide a very promising development approach enabling the Java developer to focus on getting things done without having to create huge amounts of code and a lot of configuration files. The built-in support for Alfresco makes Surf a perfect framework to build your Alfresco front-end application. With the upcoming CMIS (Content Management Interoperability Services) standard we will even have a standard interface to access content repositories.

Alfresco recently released Enterprise release 3.2r. I am not sure what kind of release this is (some kind of minor release), but one of the features is repository access through Alfresco Share allowing users to browse the general document management area through Share. This is a much requested feature that makes Share more usable outside the scope of the collaboration sites. The repository library also provides the ability to browse the repository using cloud tags or categories that are applied using the Classifiable aspect.
You can enable the repository library by editing the tomcat/shared/classes/alfresco/web-extension/share-config-custom.xml file. Navigate to the Repository Library config section and set visible to true. Make sure to rename share-config-custom.xml.sample to share-config-custom.xml in case you have made no previous changes to the file. You also need to restart the server to make the changes effective.

Alfresco recently released Enterprise release 3.2r. I am not sure what kind of release this is (some kind of minor release), but one of the features is repository access through Alfresco Share allowing users to browse the general document management area through Share. This is a much requested feature that makes Share more usable outside the scope of the collaboration sites. The repository library also provides the ability to browse the repository using cloud tags or categories that are applied using the Classifiable aspect.

You can enable the repository library by editing the tomcat/shared/classes/alfresco/web-extension/share-config-custom.xml file. Navigate to the Repository Library config section and set visible to true. Make sure to rename share-config-custom.xml.sample to share-config-custom.xml in case you have made no previous changes to the file. You also need to restart the server to make the changes effective.