Showing posts with label Alfresco. Show all posts
Showing posts with label Alfresco. Show all posts

Tuesday, July 23, 2013

CSRF Policy in Alfresco Share

Since Enterprise 4.1.4, a new CSRF (Cross Site Request Forgery) Policy has been introduced in Alfresco Share.
Should you want to learn more about this, this should be useful https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)

Mostly, it does not affect you, but in some cases it does. Here are some of the scenarios.
  • You are making an XMLHttpRequest with method POST, PUT or DELETE without using the Alfresco.util.Ajax or alfresco/core/CoreXhr classes 
  • You are making a form upload with enctype multipart/form-data without using Alfresco.forms.Form 
  • You are using a flash movie inside Share to send http requests with method POST 
  • You are writing a non-browser client, i.e. a mobile app 
  • Another system is sending POST requests to your Alfresco Share server 
  • You are running Alfresco Share behind one or more proxy server(s) and I get errors… 
Of course, there are individual methods to handle these situations using CSRFPolicy configurations, however, sometimes you would want to disable this filter altogether.

For that, simply add the following code snippet in your share-config-custom.xml file.

<config evaluator="string-compare" condition="CSRFPolicy" replace="true">
   <filter>
      <rule>
         <request>
            <method>POST|PUT|DELETE</method>
            <session>
               <attribute name="_alf_USER_ID">.*</attribute>
            </session>
         </request>
         <action name="assertReferer">
            <param name="always">false</param>
         </action>
         <action name="assertOrigin">
            <param name="always">false</param>
         </action>
      </rule>
   </filter>
</config>



Thanks to Erik Winlof for the detailed information.

Thursday, September 6, 2012

Alfresco Certified Engineer (ACE)

Proud moment for me to announce, became an Alfresco Certified Engineer yesterday. It had been a good experience to review where am I after working on Alfresco for last 4 years since Alfresco 2.1

For whom, who are targeting for the certification, here are a few useful information.

 

These are areas where you will be tested.

  • The Alfresco architecture and Repository
  • Understand, design and create content models and custom object types and aspects
  • Package and deploy Alfresco extensions and modules
  • Develop extensions for the Alfresco Explorer Web Client
  • Develop applications and Services using the Alfresco APIs (Foundation Services, JCR, Web Services)
  • Understand, define, customize and deploy Advance Workflows and Task Models
  • Understand how workflows interact with content
  • Connect to external applications using Web Services and protocols like SOAP & CMIS

.

There are 80 questions and you have 60 minutes to answer these. You need to secure at least 75% to become an ACE.

.

These are courses that will help you to pass the certification

  • Alfresco Fundamentals Course
  • Alfresco Web Scripts Course
  • the Alfresco Share Configuration Course
  • API Development Training Course
  • Alfresco Workflow Training Course
However, there is no formal requirement or pre-requisite for these courses or training.

.

Here is the categories and divisions of areas the questions are structured in the certification.

Architectural Core 39%
Repository Customization 22%
Web Scripting 13%
UI Customization 14%
Web Services 12%

.

Types of questions.

  • Multiple Choice — you need to select one option that best answers the question or completes a statement.
  • Multiple Responses — select more than one option that best answers the question or completes a statement. The text states how many options are correct, such as Choose two.
  • Sample Directions — read the statement or question. From the response options, select the option(s) that represent the most correct or best answer(s) given the information provided.
  • True/False — select either true or false as the answer.
  • Hotspot — you have to click on the correct area within an image. There is only one correct answer to this type of question.

Wednesday, August 22, 2012

Hiding the Header bar of Alfresco Share portlets in Liferay

Recently I was creating a demo for one of our customers who wanted to use Share portlets in Liferay.

Environment: Alfresco 4.0.2, Liferay 6.1.0

The Share portlets were easily deployed and working in Liferay. However, the default Share header bar was not expected inside the portlet.


It was presented like there are two navigation bars in your screen - one is from Liferay navigation, another of Share Header.

Thus I needed to get rid of the header, but since the same page as of Share application is used in the portlet container as well, I couldn't simply get rid of the header.

Added a few lines in site-webscripts/org/alfresco/header.get.html.ftl file.

<#assign portlet = context.attributes.portletHost!false>
<#if portlet>
    <#assign todo="we are not displaying header in portlet context. so nothing to do">
<#else>
    <#-- The original Header generator FTL code goes here -->
</#if>

It made the header bar not rendered while in Portlet, but the bar was as usual displayed in the Share application.


Friday, May 18, 2012

Organizations, in order to implement and adapt Alfresco as the ECM solution for the enterprise, need to follow certain plan and path.

Here we will elaborate what should be the specific plan of action for implementing Alfresco as the ECM solution in the business.

 

Identify Content Sources

In an organization, Content can be produced from a variety of sources.
For example Email transactions, Business Document productions, Images, Media file generation processes etc. Identification and listing of all these sources are quite essential.
There should be particular life cycle of each of these contents in the business, capturing these is also equally required.

 

Identify Actors

Similarly as there are number of different content sources possible in an organization, there can be variety of people and system actors involved in the production and maintenance of the content.
It is important to list down all such actors who contribute and participate in any phase of the content life cycle, along with their roles and actions they usually perform. This will also help to structure the permission model of the system.

 

Create Organization Taxonomy

This is probably the most important thing to do while establishing an ECM system. This involves
  1. Creating standard and fixed set of content Tags for the business
  2. Creating content categorization hierarchy and structure
  3. Creating user folksonomy strategy
  4. Create business specific content metadata, content types etc

 

Design Content Storage Structure

This is all about how different types of contents will be stored in the repository.
Answer the questions such as how many Sites will be created, what will be the default space (folder) hierarchy in each of the sites, what are the standard folder templates that can be re-used in the system etc.

 

Identify Document Management features

There are several standard document management features available in Alfresco ECM. For example
  • Versioning
  • Check-In, Check-Out
  • Comments
  • Manage Permissions
  • Manage Content Types, Metadata
  • Copy, Move, Edit
  • etc
The business needs to identify which all features they need and how to use them.

 

Structure Content Business Process

In an organization, contents are not created without any processes behind them.
Identifying and structuring these business processes and workflows are one of the most important aspects of an ECM implementation.
Write and spec these workflows in flow chart format that can help developers to easily implement them.

 

Collaboration around Contents

Alfresco is not only a simple document management system, it offers rich set of Web 2.0 collaboration features.
In today's social media driven world, users work in a very collaborative and connected environment. Alfresco offers all standard collaboration stuff which organizations must evaluate and implement accordingly.

 

Implement the above standard features

Deploy the above standard ECM use cases, run for a period, evaluate the performance and functionalities of the system.

 

Finally, identify and implement Customizations

At this point of time, the business owners should be pretty clear about what they need from Alfresco, as the ECM solution of the business. Now you can write down the business specific customizations, additional features they want. Implement those functionalities and you have a stable ECM solution in the business that will last long.

Tuesday, May 15, 2012

Setting up your Browser to use Alfresco Search

In Alfresco 4, OpenSearch is by default enabled.
You, however, need to configure this in your browser.

  • Open URL [http://localhost:8080/alfresco/service/api/search/engines] (replace localhost and 8080 with your alfresco server url). If OpenSearch is enabled, the following screen should come up.

  • While this page is open, click on the browser search engine drop down on the right hand side of the address bar.

  • Click on "Add Alfresco Keyword Search" - Alfresco OpenSearch search engine has now configured in your browser. 
  • Choose this search engine, type something in the search box, press enter. 
  • Alfresco would ask you for user credentials (if not logged in in Alfresco Explorer in this browser session). And as per your user credentials, the content search output will be displayed.

    Note:

  • Alfresco takes care of the user permission and scope automatically. There is no need to do any enhancements for this. 
  • The search executes onto across repository (as per the permission), this is not limited to only ''Sites''. 
  • The output is paginated. Also, the name of the document enables you to download this.

Thursday, August 4, 2011

Alfresco 3 Cookbook: what it covers?


Chapter 1, Getting Started
Chapter introducing alfresco with brief demonstration of the alfresco Explorer application. Get alfresco downloaded and installed in your machine, and finally be acquainted with the default distribution and architecture of alfresco.

Chapter 2, Creating and Organizing Contents
Understand how to use alfresco as the Content Management System, how to upload or create contents, how to apply tagging or categorization of content, understand content metadata, use the document versioning capability of alfresco.

Chapter 3, Securing and Searching Contents
Be familiar with another important aspect of the Content Management System – Security. Understand how to secure your contents and folders. How to create users and user groups – and assign permissions for who can do what. You will also know about the search capabilities offered by alfresco, how to search contents and how search works in alfresco.

Chapter 4, Rules – the Smart Spaces
Learn how to make your alfresco repository dynamic, how to implement your business requirements that works automatically in the repository. You will understand how to create and apply rules in the repository; you will also be familiar with different actions that can be performed via a rule.

Chapter 5, Administering Alfresco
Chapter with recipes for administering alfresco, demonstrating how to manage users, user groups, create taxonomies, manage content categories. You will also be aware of how to use the alfresco Node Browser to view and search contents stored in the repository. You will also know how to manage your alfresco explore r dashboard.

Chapter 6, Customizing Alfresco Web Client
Alfresco offers customization of the Web Client application via a number of XML configuration files. This chapter elaborates various recipes for changing the view and appearance of the web client, customizing the application as per your requirements etc.

Chapter 7, Alfresco Content Model
Designing and modelling the content properties and architecture is one of the important requirements in a Content Management System. Alfresco offers pretty much dynamic capabilities for designing the content models. Using these recipes you will be able to understand the core architecture of alfresco content models, create your own custom content models, use your custom models in the alfresco explorer application.

Chapter 8, Alfresco JavaScript API
Alfresco offers the repository functionalities in form of JavaScript APIs. In this chapter you will understand the API structure and available features offered. Several example recipes would help you implement various functionalities. You will also learn how to write and execute scripts, how to debug scripts written using the APIs.

Chapter 9, Freemarker Templates
Freemarker Template is the presentation layer technology used in alfresco applications. The recipes of this chapter would help you understand the technologies and model behind the Freemarker templates in alfresco. Several template examples are included for commonly used functions such as displaying folder contents, showing workflow tasks, showing contents recursively, displaying content properties and details etc.

Chapter 10, Web Scripts
Alfresco Web Scripts provide RESTful APIs of the repository services and functions. The chapter elaborates all related concepts, knowledge and how-to recipes that would help you writing, deploying, debugging, using web scripts. You will also know the usage of default web scripts library that come with alfresco. Several sample web scripts are included, for example sending emails using templates, searching and displaying documents etc.

Chapter 11, Working with Workflows
Workflow implementation is one of the major requirements in a Content Management System in a business. This chapter would help you understand alfresco business process engine in detail. You will understand how the workflows are implemented in alfresco repository along with various components of the workflow engine. Several detailed examples and recipes are included to guide you create custom workflows, custom task models, specific resource bundles, customizing the web client to render the custom tasks and workflows properly. You will also be able to use the alfresco workflow console interface which is useful for debugging the task execution within the BPM engine.

Chapter 12, Integrating with MS Outlook and MS Office
Alfresco can be used from several other applications and interfaces. Being a content management system it is quite important to have the alfresco repository accessibility from some popular content authoring applications such as Microsoft Office. This chapter helps you integrate the alfresco repository with MS Word, Excel and PowerPoint. Recipes are also included for communicating with repository directly from any standard email client application such as MS Outlook.

Chapter 13, Configuring Alfresco E-mail and File Servers
The alfresco repository can act has file servers as well and you can expose the repository using several other standard protocols such as FTP, CIFS, WebDAV etc. These recipes are step-by-step guide to configure these protocols and using the content repository from different systems. From this chapter you will also be able to use alfresco as email server, and emails sent to some specific address will be landed directly into the repository.

Chapter 14, Building Alfresco
Until now you have used Alfresco as the binary bundle provided and downloaded. Now you can compile and build alfresco source code also. Recipes in this chapter will guide you to get the source from alfresco source code repository, compile and build the source code. You can modify Alfresco source code as your will; of course as per Alfresco license, you should contribute your changes back to alfresco community.

Thursday, July 28, 2011

Alfresco 3 Cookbook: for whom?

Alfresco 3 Cookbook – Recipes for Practical Usage of Alfresco.



The book is a collection of knowledge articles and recipes stating and demonstrating the most important, useful and imperative concepts and functionalities of Alfresco.

The book is designed purely for Alfresco Developers and System Integrators - from beginner to advanced level.



  • If you are a software developer, interested in content management systems, want to work in alfresco or already experienced in alfresco, you need very objective set of instructions on how to perform certain tasks in Alfresco.
    Alfresco 3 Cookbook is a developer’s friend to start working on alfresco quickly, getting complete understanding, writing custom implementations and achieving the expertise very easily.
  • As alfresco administrator and architect, you will know how to compile, deploy, install, configure and customize alfresco.
  • If you are a system integrator, you will be able to establish alfresco as a corporate enterprise content management solution.

The book is written for software developers who needs to know more on Alfresco, write applications and extensions on alfresco, very quickly, in order to implement their own ECM system.

The book is structured as a collection of recipes for real-world problems and requirements. Each recipe includes the problem/requirement definition, step-by-step instructions to fulfill the requirement (How to do it) and a complete analysis (How it works) of the solution. Corresponding screenshots and complete code segments are also included.

Step-by-step instructions are given on how to compile, build, deploy, install and configure alfresco.

As a developer or architect you can follow the guidelines, implement the scenario by yourself, understand how it is working and finally gain expertise on mostly all aspects of alfresco development and customization.

Wednesday, July 27, 2011

Alfresco 3 Cookbook: Credits

Yesterday Packt Publishing published my first book on Alfresco titled Alfresco 3 Cookbook (http://www.packtpub.com/alfresco-3-cookbook/book).

I would like to thank PucktPub for publishing.the book.

Here are the people whose contribution has made the book a success. I sincerely thank all of them and appreciate all their help and efforts.

Reviewers

Piergiorgio Lucidi
Adit Patel
Khazret Sapenov
Snehal Shah

Acquisition Editor

Steven Wielding

Development Editor

Alina Lewis

Technical Editor

Gauri Iyer

Copy Editor

Leonard D'Silva

Project Coordinator

Shubhanjan Chatterjee

Proofreader

Mario Cecere

Indexer

Tejal Daruwale

Graphics

Nilesh.R.Mohite

Production Coordinator

Adline Swetha Jesuthas
Arvindkumar Gupta

Cover Work

Adline Swetha Jesuthas

Friday, July 15, 2011

Short Comparison of Alfresco flavors

Alfresco Team - "If you are looking to just get started with Alfresco or need a supported, departmental solution for content collaboration, then Alfresco Team is for you."

Here is a short and brief comparison of three different flavors of Alfresco (from Alfresco Mailing List).

Saturday, February 5, 2011

Organization Hierarchy in Alfresco

Alfresco, as we know, does not support implementation of Organization Hierarchy.
For example, you cannot establish the hierarchy of your Organization via the user details in Alfresco.

Very often, you need setting up the user hierarchy in the ECM system, for example if you want to implement automatic assignment of tasks to your superior.

You, however, can use the owner property of the user object to store the superior's user-id. Thus you can have full parent-child relationships between users in alfresco.

You can also create a custom aspect having the properties reflecting hierarchy information, associate that with user type (cm:person), and hold the relevant data into that.

One interesting implementation of this is, if you have your organization hierarchy stored in your AD or LDAP, you directly import this information while synchronizing the user data with alfresco. In the post on Alfresco Authentication and Integration with Active Directory, I have given some example on synchronizing the LDAP attributes into alfresco like

ldap.synchronization.userLastNameAttributeName=sn
ldap.synchronization.userEmailAttributeName=mail
ldap.synchronization.groupIdAttributeName=cn


You can add another custom synchronization setting along with these to import the Boss Id of the current user.


For Businesses

Implementing and Storing the Organization Hierarchy in an ECM system like Alfresco has quite a few business advantages. Implementing automatic workflows within departments requires the system to know the manager's id of the user.
You can implement the departments of your organization as Sites in Alfresco Share; however, the roles Collaborator, Contributor etc are not hierarchical, and thus unable to translate the pecking order of a particular organization. One way to implement this is to create groups and sub-groups as per departments.

Tuesday, January 25, 2011

Task Comments in Alfresco jBPM workflow as process variable

It is very powerful to have alfresco JavaScript APIs accesible in node event scripts in jBPM workflows.

Most of the workflow variables are accesible in jBPM process definition in alfresco.
Such as bpm:assignee is available as bpm_assignee, bpm:workflowDueDate is available as bpm_workflowDueDate, bpm:workflowPriority as bpm_workflowPriority etc

But the task Comments entered by the user is unfortunately not available directly. However, you can still access it by the following syntax in the script.

var comment = ""; 
if (token.comments.size() > 0) 
    comment = token.comments.get(0).message;

The comment variable is now available in your script.

Saturday, January 15, 2011

Alfresco Authentication and Integration with Active Directory

One of the main features of the Alfresco ECM System is the ability to integrate user authentication and synchronization with almost all popular LDAP directory servers, such as Microsoft Active Directory.



However, the integration is error prone and requires understanding of your LDAP environment settings and configuration. Moreover, as a warning, I must say the error messages you will face during the integration are most of the time mis-leading and subjective.

In this article, we will see how we can integrate alfresco with AD; and also how to synchronize alfresco users and groups with the existing entities of your AD. I have used alfresco 3.3.4 in this case.

Be prepared with the settings of your AD so that you can understand and configure your alfresco as well.

Alfresco Subsystems

There are a few subsystems offered in alfresco installation.
  1. Audit
  2. Authentication
  3. File Server
  4. IMAP
  5. Synchronization
  6. EMail
We will use the Authentication and Synchronization subsystems for this purpose.

Authentication Subsystem

For authentication purpose, alfresco can be configured with AD, LDAP, Kerberos, alfrescoNtlm or other external servers. You can configure alfresco to authenticate from a number of systems - this is known as Authentication Chain.
You define the authentication chain in alfresco-global.properties file or in repository.properties file.

By default, the authentication chain is defined as (in repository.properties file)

authentication.chain=alfrescoNtlm1:alfrescoNtlm


Thus, only alfrescoNtlm authentication is activated.
For enabling AD authentication, we put it as

authentication.chain=ldap-ad1:ldap-ad,alfrescoNtlm1:alfrescoNtlm


Now alfresco will try to authenticate the user first from the configured AD, and if the user is not present there, alfrescoNtlm will be tried. If you put only ldap-ad1:ldap-ad, alfresco local authentication will be fully stopped. In this way, you can integrate a number of systems into alfresco authentication chain.

Configuring Active Directory Authentication

In webapps\alfresco\WEB-INF\classes\alfresco\subsystems\Authentication, we have separate folders for separate servers. For our Active Directory integration, our settings should be populated in the ldap-ad-authentication.properties file in ldap-ad folder.

This file is used to set the configurations on Authentication as well as Synchronization with AD.

ldap.authentication.active=true
This value should be true in order to make the authentication mode activated.

ldap.authentication.userNameFormat=%s@mydomain.com
This value pattern will be used when users will put the user name in the alfresco login dialog and try to be authenticated. This value should be full User Principal Name (UPN) or DN.

ldap.authentication.java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory
No need to change this line. We use the default Sun Java LDAP libraries.

ldap.authentication.java.naming.provider.url=ldap://<<server-name or ip>>:389
Put your AD server name or IP here. 389 is the default port for LDAP services, consult your administrator in case you have different port.

ldap.authentication.java.naming.security.authentication=simple
This value can be simple, digest-5 etc. Again, depends on your AD setup.


ldap.authentication.escapeCommasInBind=false
ldap.authentication.escapeCommasInUid=false
We won't change these values.

ldap.authentication.defaultAdministratorUserNames=administrator
Put your administrator user name here.

These values and settings are enough to make alfresco authenticate against your Active Directory. However, we also need synchronization between your AD and alfresco, so that users and groups are imported into alfresco and you can manage the permissions and restrictions of the users.

Configuring Active Directory Synchronization

Same file is used to populate the synchronization settings.

ldap.synchronization.active=true
True means alfresco will try to import AD users and groups into local system.

ldap.synchronization.java.naming.security.principal=CN=Administrator,CN=Users,DC=domain,DC=com
Put your administrator user DN here.

ldap.synchronization.java.naming.security.credentials=****
Put your user password here - in plain text.


ldap.synchronization.queryBatchSize=1000
ldap.synchronization.attributeBatchSize=1000

We do not change these values for now.

ldap.synchronization.groupQuery=(objectclass\=group)
The objectclass of your Groups in AD.

ldap.synchronization.personQuery=(&(objectclass\=user)(userAccountControl\:1.2.840.113556.1.4.803\:\=512))
The objectclass of your Users in AD.

ldap.synchronization.groupDifferentialQuery=(&(objectclass\=group)(!(modifyTimestamp<\={0})))
Pretty standard, change the objectclass only, if required.

ldap.synchronization.personDifferentialQuery=(&(objectclass\=user)(userAccountControl\:1.2.840.113556.1.4.803\:\=512)(!(modifyTimestamp<\={0})))
Again pretty standard, change the objectclass of users only, if required.

ldap.synchronization.groupSearchBase=DC\=domain,DC\=com
Put your AD domain configuration here for Groups query search base. I have used a generic search base here, it would probably search everything.

ldap.synchronization.userSearchBase=DC\=domain,DC\=com
Put your AD domain configuration here for Users query search base. I have used a generic search base here, it would probably search everything.


ldap.synchronization.modifyTimestampAttributeName=modifyTimestamp
ldap.synchronization.timestampFormat=yyyyMMddHHmmss'.0Z'
ldap.synchronization.userIdAttributeName=sAMAccountName
ldap.synchronization.userFirstNameAttributeName=givenName
ldap.synchronization.userLastNameAttributeName=sn
ldap.synchronization.userEmailAttributeName=mail
ldap.synchronization.groupIdAttributeName=cn
ldap.synchronization.defaultHomeFolderProvider=userHomesHomeFolderProvider

We won't change these values now. These are used to populate the user attributes from AD.


ldap.synchronization.groupType=group
ldap.synchronization.personType=user
ldap.synchronization.groupMemberAttributeName=member

These values also may not be changed for now.

That's it!
Restart your server, alfresco should connect to your AD and import all users and groups. For authentication, it should go to your AD and validate the credentials.

Important!

In community version, you need to add this XMl tag in common-ldap-context.xml file in subsystems\Authentication folder.
Under the following tag -
<bean id="ldapInitialDirContextFactory">
<property name="initialDirContextEnvironment">
<map>


Add this entry -
<entry key="java.naming.referral">
<value>follow</value>
</entry>

Tuesday, November 23, 2010

Site create permission restriction on 3.4

Alfresco guys has been broadcasting about restricting Site Create permission to users. Earlier all users could create Site on their own. There was no feature or permission set to control who can create Site and who not.

However, in 3.4, they have introduced a mechanism to restrict this.
http://wiki.alfresco.com/wiki/Site_Service#Controlling_who_can_create_sites

But is this solution good? This mechanism was there since long, this is not new in 3.4. However, in 3.4 you can manage this using Share interface - no need to go to the Web Client. What you need to do is to revoke the Contributor privilege from EVERYONE from Sites parent folder, and when a normal user tries to create a site, a nasty error is presented. It would have been better if the Create Site link itself disappear in case a user does not have permission to do so.

Thursday, September 16, 2010

Looking forward for OSIdays...

Going for a Panel Discussion on Open Source CMSs in OSIdays at Chennai. 19, 20, 21 Sep 2010.
http://osidays.com/osidays_schedule.html

Expecting tough competition from Drupal people... not surprisingly.

Sunday, September 12, 2010

Alfresco 3 Cookbook... progressing

Sent first couple of chapters for review to Packtpub. Looks Ok. I expected at least some feedback etc...

Curiously waiting for the dates of launch...

Monday, August 30, 2010

My First Book by Packtpub!!

Well, well, started writing my first book.
It is a Cookbook - for Alfresco 3.
Packtpub is the publisher for me.

Just completed the formalities a month earlier or so. It has been a very good experience till now working with the competent and understandable team of Packtpub. We signed the contract after a few initial glitches with my lawyer.

This has been my long kept aspiration for writing books. Well now its started. I have quite a number of titles in mind for writing books. Hope the first title starts well, and does well!!

Though have started this journey with a core technical one, I would want to explore non-technical titles as well. During my school days I had drafted a few science fiction plots. That period you read all those stuff, get amazed and react in several different ways. Well, I drafted some sci-fi's!!

Lets see how this journey keeps up...

Saturday, January 9, 2010

Building Solutions on top of Alfresco

Alfresco offers several products from its entire solution framework such as Document Management, Web Content Management, Collaboration. Furthermore, and more powerfully it offers the Content as Platform and Service.

This makes building your own business ready solution development very easy. As said in http://www.alfresco.com/products/platform/features/ there area few features that developers like - what Alfresco has successfully achieved is exposing most (if not all) of its functionalities as REST services over HTTP. The source code bundle of Alfresco comes with around 300+ REST services, using which developers can very quickly implement a new solution altogether, and can integrate Alfresco in existing stack in a very loosely coupled SOA based architecture.

There are several models of building solutions on top of and using Alfresco. I will discuss one of the models here. It uses Alfresco REST services (more popularly known as Web Scripts).



In this model, Alfresco would act as a Content Database exposing various services and APIs to architect and develop solutions on top of it. Several services has been exposed such as Content (Nodes), Workflow, Rules, Security, Session, Thumbnail, Content Model etc. More importantly these services has been exposed as JavaScript API (http://wiki.alfresco.com/wiki/JavaScript_API) making it very easy for developers to implement different functionalities.

Using several JavaScript and/or Java services and APIs provided by the Alfresco engine, we can create REST services which can be invoked by any Client Application (irrespective of underlying technology on which the client application is implemented). In this way, we can implement a new client application altogether or we can add Alfresco's rich CMS and other functionalities in any existing systems.

This methodology can be also used in order to implement SOA architecture based systems in existing infrastructure.

Tuesday, September 22, 2009

Liferay and Alfresco VS. Liferay or Alfresco

Long since Liferay and Alfresco stormed into Open Source Industry, business owners and developers are working on integrating or using these two frameworks and generating some business solutions using these.

At a time, the focus of these two softwares were (still are?) entirely different. For example,

Liferay is by heart a portal solution with a very strong & active community behind it and an impressive clientele to prove its credentials. By far it is in today's days, arguably, the most popular open source portal solution, specially in Java technology.

Alfresco is an Enterprise Content Management Software which also has an equally powerful & vigorous community supporting it and an imposing set of patrons using the software. This is again, the most admired ECMS solution available in today's open source market.

Liferay has been wonderful in handling portal problems in the industry and its scalability have been the main driver that helped itself to be adopted in a variety of business verticals. However, as since its primary focus has been a portal solution, the document and content management capabilities of this framework does not make it very much enterprise ready, and not at all extensible, specially if we compare it with proper document and content management systems. However, the collaboration features of Liferay are definitely quite powerful.

On the other hand, Alfresco has been fantastic as an Enterprise Document and Content Management solution. The framework's architecture, functionality and extensibility makes it really the best choice for an enterprise business. Having features like customizable workflow, templated UI, user-defined data-types, powerful rules engine etc makes this one of the best ECMS solution. Conversely, since it is not intended to be a collaboration solution, these features are not very well provided, at least not suitable for business users.


Integrated Solution


In this scenario, these two technologies seems to be very much complementary to each other - Liferay providing the portal environment while Alfresco sits at the lower level of the stack supplying the content management services.

Alfresco Web Script is a very great framework which makes this solution even more feasible and extensible. Web Scripts can be used as a pltaform of SOA architecture based solution as well as these can be used as standard JSR portlets deployed in Liferay. Both these technologies support Single Sign On with standard LDAP providers.


New Offerings


However, now both these solutions have now come up with new products in order to capture the market with focus and to provide a ready-made solution to the business. Quite excitingly, both these prodcuts seems to be targeting the same market segment - Collaborative Document Management System.

Liferay has launched Liferay Social Office http://www.liferay.com/web/guest/products/social_office, offers features such as Wikis, Blogs, Document Libraries, Calendar, Sites, Message Boards, Activities etc - http://www.liferay.com/web/guest/products/social_office/features.

On the other hand, Alfresco has also launched Alfresco Share http://www.alfresco.com/products/collaboration, offering almost similar features like Document Library, Sites, Wikis, Blogs, Activities, SharePoint protocol support etc.

Although the behavior and presentation of these two systems are different, features and functionalities offered by these are very much similar.


Big Question


Now the big question is, where these two systems are leading into? As the document management, record management features are not main focus of Liferay, similarly the collaboration features are not the most important offerings of Alfresco.

It will be quite interesting to see in next few months or years how these systems grow and place themselves as complementary or competitive solutions.

Wednesday, July 29, 2009

Tutorial: Building Alfresco web scripts, deploying as Liferay Portlets - Part 4

Deploying the Web Scripts as Liferay Portlets

Well, we now are able to create and build web scripts both by Java and by JavaScript.
Now, we want our web scripts to be displayed in Liferay portal as portlets.

For that, we need to update the following xml files in order to register the alfresco web scripts in Liferay portlet list. These files are in C:\mystackroot\webapps\alfresco\WEB-INF folder.

For deploying the Alfresco web scripts in Liferay, you need to add the information of the web script (as portlet) in 4 XML files, restart your server, and Whoa - you are done.


web.xml

  • Register the Web Script as a servlet.
<servlet>
<servlet-name>myfirstscript</servlet-name>
<servlet-class>com.liferay.portal.kernel.servlet.PortletServlet</servlet-class>
<init-param>
<param-name>portlet-class</param-name>
<param-value>org.alfresco.web.scripts.portlet.WebScriptPortlet</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
  • Register the Servlet mapping.
<servlet-mapping>
<servlet-name>myfirstscript</servlet-name>
<url-pattern>/myfirstscript/*</url-pattern>
</servlet-mapping>
  • In this way, register all the web scripts as servlets to be deployed as Liferay portlets.



portlet.xml

Register the web scripts as portlets
<portlet>
<description>myfirstscript</description>
<portlet-name>myfirstscript</portlet-name>
<portlet-class>org.alfresco.web.scripts.portlet.WebScriptPortlet</portlet-class>
<init-param>
<name>authenticator</name>
<value>webscripts.authenticator.jsr168.webclient</value>
</init-param>
<init-param>
<name>scriptUrl</name>
<value>/alfresco/168s/infoaxon/repository/ myfirstscript</value>
</init-param>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
</supports>
<portlet-info>
<title>My First Web Script</title>
<short-title>My First Web Script</short-title>
</portlet-info>
</portlet>



Few points to be noted here:
  1. portlet-name should match the web script name
  2. scriptURL should be like /alfresco/168s/<<web-script-url-as-defined-description-xml>>
In this way, register all the web scripts to be deployed as Liferay portlets.


liferay-portlet.xml

Define the web scripts as portlets
<portlet>
<portlet-name>myfirstscript</portlet-name>
<use-default-template>true</use-default-template>
<restore-current-view>true</restore-current-view>
</portlet>
  • The portlet-name must be same as defined in portlet.xml file.
  • In this way, define all the web scripts to be deployed as Liferay portlets.



liferay-display.xml

Describe how the portlets will be displayed in Liferay portlet list
<portlet id="myfirstscript"></portlet>

The portlet id should match the portlet-name defined earlier.
You can define your own category in which you would like see your portlets in Liferay.
<display>
<category name="My Custom Portlets">
<portlet id="myfirstscript"></portlet>
<portlet id="helloworld"></portlet>
</category>
</display>

In this way, define all the web scripts to be deployed as Liferay portlets.


Congrats, All Done!!!
  • Restart your server.
  • Navigate to Liferay and login as a user with suitable permissions to add a portlet is a page.
  • Open the Add Application popup in liferay. You should see My Custom Portlets category in the list and the portlets you have just registered under it.
  • Drag your portlet in the page and enjoy!

Tuesday, April 14, 2009

Tutorial: Building Alfresco web scripts, deploying as Liferay Portlets - Part 3

Creating a Web Script using Java

Step 1: Create the Source Code Folder Hierarchy
  • Decide the package structure and URL of your web scripts.
  • For example, if we create web script in package com.infoaxon.repository
  • In this case, our folder structure would be <<root>>\com\infoaxon\repository. The Java source files will start from this folder.
  • Our all Java source files would be in the repository folder or in any of the subfolders, as per the package design suggests.
  • We will later on create a jar of all these classes.
  • One jar should ideally represent one module in Alfresco, hence if we plan to create a number of alfresco modules, we should design our packages accordingly.
  • One alfresco module can have any number of web scripts, and any number of different packages. So technically speaking, there is no need to create a number of modules for different packages; however, still creating separate modules might be a clean design approach.

Step 2: Create the main Java Class
We will now write the main Java class which will be responsible for generating the web script. This class must be inherited from org.alfresco.web.scripts.DeclarativeWebScript class and must implement executeImpl method.

Here is a sample class code

package com.infoaxon.repository;

import java.util.HashMap;
import java.util.Map;
import java.net.InetAddress;

import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.scripts.WebScriptRequest;
import org.alfresco.web.scripts.WebScriptStatus;
import org.apache.log4j.Logger;

public class myfirstscript extends org.alfresco.web.scripts.DeclarativeWebScript {

Logger logger = Logger.getLogger(myfirstscript.class);

@Override
protected Map executeImpl(WebScriptRequest req, WebScriptStatus status) {
Map model = new HashMap();
String txt = "";
try {
txt = "Hello, Well Done!!! You seems to be got it, this is coming from Java!!!";
} catch (Exception e) {}

model.put("servertext", txt);
return model;
}
}


This class will simply return a hashtable with only one key named servertext. The web script Freemarker template than would take this variable, and would display.

Now to compile this one (assuming the file name is myfirstscript.java):
javac -cp C:\mystackroot\webapps\alfresco\WEB-INF\lib\alfresco-repository.jar;C:\mystackroot\webapps\alfresco\WEB-INF\lib\alfresco-web-client.jar;C:\mystackroot\webapps\alfresco\WEB-INF\lib\log4j.jar myfirstscript.java

This would create myfirstscript.class


Step 3: Package the Class
Now we will package the class, i.e. create jar of this.
For that, go to the root folder (mind that, we are in <<root>>\com\infoaxon\repository folder, and we have create our class and Java files there only). To create the jar:
jar -cvf <<jar-name>> <<root-package-name>>

For example in our case, jar -cvf myfirstscript.jar com
This should create the jar file with root namespace (package) as com.


Step 4: Deploy the Jar
As you know, to define a web script, we need to have:
  1. A description xml file, in our case the name would be myfirstscript.get.desc.xml
  2. An FTL file generating HTML code, in our case the name would be myfirstscript.get.html.ftl
  3. Optionally, a JS file, in our case the name would be myfirstscript.get.js
These files need to be created in C:\mystackroot\webapps\alfresco\WEB-INF\classes\alfresco\templates\webscripts\ folder hierarchy.
  1. Create subfolder hierarchy com\infoaxon\repository under C:\mystackroot\webapps\alfresco\WEB-INF\classes\alfresco\templates\webscripts\ folder.
  2. Under the repository folder, create the following three files:


myfirstscript.get.desc.xml
<webscript>
<shortname>My First Java based Web Script</shortname>
<description> My First Java based Web Script</description>
<url>/infoaxon/repository/myfirstscript</url>
<authentication>none</authentication>
</webscript>


myfirstscript.get.html.ftl
<html>
<body>
<p>${servertext}</p>
<p>${jstext}</p>
</body>
</html>


myfirstscript.get.js
model.jstext = "Hello, what do you think, this is coming from JavaScript!!!";


Step 6: Define a Alfresco Module that binds and deploys the Web Script
Now we need to create an alfresco module that binds the web script.

Alfresco modules are defined and deployed in C:\mystackroot\webapps\alfresco\WEB-INF\classes\alfresco\module folder. We need to register our web script as module in this folder only, so that next time when the server boots, it reads this module and deploys in Alfresco.
  • Create a folder here with name as you think properly represents your module. In our example, we create the folder named myfirstscriptmodule. Note: there is no restriction in module name; in other words, there is no binding in web script name, package name and module name. So you are free to use anything as your module name.
  • Under the myfirstscriptmodule folder, we need to create at least two files (by these names only):
module.properties:
This file renders the details of the module. A typical module.properties file looks like:

#Mon Jul 21 18:34:18 IST 2008
module.version=1.0
module.description=My First Web Script
module.id=myfirstscript
module.repo.version.max=999
module.title=My First Web Script
module.repo.version.min=2.1
module.installState=INSTALLED
module.installDate=2008-07-21T18\:33\:45.875+05\:30


module-context.xml:
This file registers the web script implementation Java class files as beans.
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
<bean id="webscript.com.infoaxon.repository.myfirstscript.get" class="com.infoaxon.repository.myfirstscript" parent="webscript">
</bean>
</beans>


There are a few important things to be noted in this file:
  1. The bean id naming convention is strict:
  2. It must start with keyword webscript, thus Alfresco comes to know that this bean is a web script implementation bean
  3. The further name parts should match the web script package and web script name
  4. The class name should exactly match with the name of the web script along with its package
  5. The parent should always be webscript, since the implementation class is a web script.

Step 7: Start Server: Test your Web Script
That’s it, is everything goes fine, you have just created your first Java based custom web script.
  • Start tomcat server
  • In your favourite browser, navigate to http://localhost:8080/alfresco/service/index. Find your web script and test whether it is working.

In the next installment of this tutorial, we will discuss about how we can deploy the web script as a JSR-168 portlet in Liferay.

Happy Scripting!!!