Apache Lenya - unusual opensource CMS in Java

    In the comments on the Spring topic in action - trying openource CMS in Java, I mentioned Apache Lenya, one of the open source CMS in Java, and I was asked to write more about it.
    Apache Lenya Logo

    Why Apache Lenya


    “Why CMS in Java?” - The first question that arose when I received requirements from the customer. The answer was simple: the customer, a large corporation, had experience in developing projects in Java, so I trusted her the most. “Java EE” sounds more serious and reliable for a businessman’s ear than, say, PHP. The situation with reliability and seriousness is not really important, but it is worth considering that large corporations trust the products of other large corporations.

    So, we in the company began to look for Java CMS. It turned out that there are not so few of them, both paid and freely distributed. More details can be found here on Wikipedia
    After analyzing the licenses, and we needed to seriously “finish” the CMS for the needs of the customer, the choice was made by several candidates: Nuxeo EP, Daisy, Hippo CMS, Alfresco and Apache Lenya itself. All have been tested. After analyzing the source code and assessing the complexity of the development, we decided to stop at Apache Lenya. This CMS provided the widest possible source code changes that were readily available. Fortunately, the Apache License allowed changing the code and then using the product for commercial purposes. The problems that arose at the beginning were solved with the help of a small, but rather active community.

    Main manu bar

    Features of Apache Lenya


    Apache Lenya provides standard CMS features (I only have Joomla experience, so most of the comparisons with it):
    • WYSIWYG content editor. Even 2: Kupu and BXE. The more familiar FCKEditor is easily added.
    • Form editor for cases when the regular WYSIWYG editor fails
    • Lock editable pages to prevent situations when the same page is edited by multiple users
    • Internationalization
    • Schedule content publishing
    • Moving, copying, archiving, deleting both individual pages or individual parts of the site
    • XHTML + CSS to Separate Content and Appearance
    • Ability to transfer pages to the archive
    • Differentiation of access rights of users and user groups to different pages or parts of the site
    • Integrated Site Search (Apache Lucene)

    And also not the most ordinary:
    • Version control. Any edited page can be rolled back a few revisions.
    • Editable page life cycle. One and two-stage draft-published cycle included in delivery
    • Dividing the site into sections: Development, Published and Supporting (Staging)
    • All operations are recorded in the operation log.
    • Configuration data is stored in files. If you wish, you can replace classes that provide reading / writing data with classes that work with the database
    • LDAP user authentication

    Features:
    • The concept of "Publications"

    This concept allows you to reuse the already created site structure (or the structure and data of one publication) for a new publication. Various publications may use the general structure of the site, but contain different information. For example, there is a publication by default, default, which already contains XSLT templates, data about the user, user groups, and other service information. Publishing production inherits from default. Then the production publication has the same appearance (thanks to the common XSLT), access to all users and groups. However, it can override some user rights, rendering pages, or in general the whole thing. In general, a fairly convenient feature if you need to support several similar sites.
    • Assembled with Apache Ant
    • Apache cocoon

    This web-framework should be discussed separately in a little more detail. He is the heart of Apache Lenya.

    Apache cocoon


    Apache Cocoon ( off. Site ) - a framework for web development. It has similarities with the Spring Framework when it was still version 2 or even younger. Among other things, it is worth noting, in my opinion, the two main features of Cocoon: the presence of an IoC container and the concept of "channels" (pipelines). It has many other notable features, but it was these two that I needed when finalizing Apache Lenya. What is Inversion of Control, I think, it’s not worth describing, but a few words should be said about the “channels”.
    “Channels” is a kind of implementation of the MVC pattern. The XML configuration looks something like this:



      
      
        
                    our docs processed by doc2html.xsl -->
          
            
            
            
          


                    our docs processed by doc2pdf.xsl -->
          
            
            
            
          

        

      



    * This source code was highlighted with Source Code Highlighter.

    As you can see, there are three main steps to creating pages in mapping:
    1. Generation
    2. Transformation
    3. Serialization

    In curly brackets, parameters for the generator are passed.
    In this way, flexibility and a high level of reuse of components are achieved: using the same generator and different transformations and serializations, you can get a wide range of output data formats from banal html to pdf or csv.

    To implement the IoC container, Apache Cocoon uses the currently closed Apache Avalon framework. The whole configuration is in the cocoon.xconf file. It contains almost everything: components, data sources, module declarations (Cocoon has a flexible plug-in system), and more.
    There is not much documentation on this all over the Internet, so a little more detail about the components.
    The concept of components looks something like this: several components (component) are united by the role (role), the default role implementation is declared, and in the Java class you can already use the role and its specific implementation. Roles are interfaces, and components are concrete classes. I will not give specific file listings, they are very large. The details of Apache Cocoon and Avalon require a separate article.

    Install Apache Lenya


    After downloading apache-lenya-2.0.3-src.zip and unpacking it, which may take a long time due to the larger number of files, it must be compiled. Here begins the biggest "dances with a tambourine."
    I managed to build version 2.0.2 by executing in the root:
    >build build-cocoon
    >build build-cocoon
    >build

    This is not a clerical error; the first command must be executed twice.
    For version 2.0.3, everything turned out to be much more complicated.
    First, in the externals \ cocoon_2_1_x \ lib \ optional directory , you need to update xalan-2.7.1.jar so that it contains package org.apache.xpath, and add serializer.jar from the xalan-j_2_7_1-bin.zip distribution . By the way, after updating xalan-2.7.1.jar , compilation errors may occur, then you need to look for another xalan-2.7.1.jar . I took it from the maven repository, and the serializer from the Xalan distribution.
    Next, we try to build Cocoon. To do this, we execute in the root:
    build.bat build-cocoon -lib externals/cocoon_2_1_x/lib/optional

    Once from the 3rd or even from the 4th build should pass successfully.
    The -lib parameter externals / cocoon_2_1_x / lib / optional is required, because some libraries with ant tasks are there, and some libraries are needed for compilation.
    Then, for Windows users, you need to install GnuWin32 ( you can get it from here ), add the directory where GnuWin32 is installed to in PATH from the environment variables. This is necessary so that the patch command is executed during assembly.
    As a result, the command
    build -lib externals/cocoon_2_1_x/lib/optional

    should end with the BUILD SUCCESSFUL magic message.
    If something didn’t work, then you can additionally ask me or look for answers in the mail archive

    Launch Apache Lenya


    The launch didn’t go smoothly either. First, I had to copy jms.jar (javax.jms package) and jta-1.1.jar (javax.transaction package) to build\lenya\webapp\WEB-INF\lib\(this will need to be fixed in the main ant build), and only after that Apache Lenya successfully started:
    Lenya Homepage

    Lenya starts using the lenya.bat or lenya.sh file
    By default, the Jetty servlet container is used.
    It is also possible to run under Tomcat (personally tested). You can read more about this on the official website .
    Apache Lenya is partially translated into Russian. Non-localized labels can be translated by adding the necessary data in the internationalization files: $ LENYA_HOME $ \ src \ webapp \ lenya \ resources \ i18n

    Create a new Apache Lenya publication


    To create your publication, do the following:
    On the main page, click 'Create publication', enter the ID (future context) and the publication of the name:
    Create publication

    After creating a click on a link to the publication and get to the page with the publication properties:
    Publication homepage

    Select 'Login for authoring' (allows you to edit the contents of the site and the site configuration)
    Logins like lenya (password levi)
    Choose what to do: export the default pages or not create any pages:
    Import pages

    Further, the user lenya can create pages, edit them and send them for approval. In the "Edit" menu you can create pages, and in the "Process" menu to control the status of the pages:
    Edit menu
    Workflow menu

    User alice (password levi) has the role of reviewer and has the right to publish pages. After publication, the pages appear on the Live View (or the “Published” tab).
    For help, information about users, groups and roles is stored in \ build \ lenya \ webapp \ lenya \ pubs \ default \ config \ access-control \ passwd \ Of course, they can be changed via the web interface, the 'Admin' tab.

    conclusions


    Apache Lenya is a flexible Java CMS based on Apache Cocoon, and therefore all its features, and distributed under the Apache License. This CMS has wide capabilities, as they say, “out of the box”, and the functionality can be easily expanded by writing additional modules. There is not much documentation and manuals on the Internet, but there is a small active community. Under certain conditions, Lenya can be recommended for use.
    This article only covers the basics and some of the features of Apache Lenya. If someone has an interest in this topic, I can continue the description of this unusual CMS.

    List of resources
    1. Official site Apache Lenya http://lenya.apache.org/
    2. Official Apache Cocoon website http://cocoon.apache.org/
    3. Apache Lenya Mail Archive http://mail-archives.apache.org/mod_mbox/lenya-user/
    4. GnuWin32 http://gnuwin32.sourceforge.net/packages/patch.htm
    5. List of Java CMS on Wikipedia

    Also popular now: