Building Websites with OpenCms

By Matt Butcher
  • Instant online access to over 7,500+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies

About this book

This book takes you through the process of creating content-rich websites and applications using OpenCms. Although powerful and flexible, OpenCms can be daunting on first approach, but its advanced features reward the investment in learning. This book exists to ease Java developers into getting the most from OpenCms.

OpenCms
OpenCms is a professional-level, open source Website Content Management System, with which you can create and manage complex websites. Based on Java and XML technology, it fits into almost any modern IT environment. With hard-won experience of the practical difficulties faced by developers working with OpenCms, this book is the embodiment of the author's expertise, and the perfect way to master the system.

Publication date:
July 2004
Publisher
Packt
Pages
274
ISBN
9781904811046

 

Chapter 1. Introduction to OpenCms

The purpose of this chapter is to provide a brief introduction to OpenCms and the concepts and technologies it employs. In this chapter, we will cover:

  • The concept of a Content Management System (CMS)

  • The features of OpenCms

  • The history and community surrounding OpenCms

  • A technical overview of the OpenCms project

What Is a Content Management System?

The exact definition of a CMS is somewhat slippery, as the range of CMS systems is broad and the functionalities of each differ markedly. At the core, however, a content management system provides a framework for creating, managing, and publishing documents and texts. In more practical terms, a content management system handles the process of creating and maintaining a collection (large or small) of documents.

While CMS systems in general deal with a wide variety of types of collections, ranging from memos to marketing material, web-based collections are the most high profile. To that end, many CMS systems, including OpenCms, focus on web-based management (also called Web Content Management or WCM) and delivery of content.

Three Essential Components

There are three essential components to an enterprise-class CMS:

  • Editorial workflow

  • Publishing

  • Versioning

Editorial workflow refers to the process of preparing a piece of content for production. In the simplest case, this may simply involve one person writing a document, proofing it, and perhaps also revising it. However, in a larger context, the process may involve multiple authors writing content that is then edited by a team of editors and producers. A manager may assign a topic to an individual author who then writes a document. Once the author is done with the document, a team of editors reviews and corrects it, occasionally handing it back to the author for revision. Once this iterative process is complete, the editors submit the document to a producer, who makes decisions about whether the content is to be distributed, and if so, when. A good CMS must handle both the simple and the complex cases of editing. Once a document is written, it must be published.

Publishing is the next step in the life of the document. Publishing the document makes it accessible to potential readers. Some collections of content, such as the numerous chapters in a manual, are all published together. Other content, such as a news article or a press release, may be published on its own without requiring simultaneous publishing of other material. Sometimes images need to be published along with a particular document. Sometimes the document may require a certain amount of dynamic information (such as stock quotes or live images) to be incorporated. All of these possibilities mandate an effective publishing mechanism. A document's life cycle is not complete once it's published—it now enters version control.

Versioning becomes important once a document has been published. Authors and editors may make corrections or add updated information, and these changes may require their own editorial cycle before they can be published. Changes to the document should not be immediately incorporated into the published version, but must remain in the editorial stage while the currently published version remains available. Even after the changes are published, circumstances may require that the update be 'backed out' and the prior version restored. This process of revising and updating a document while preserving a record of changes is called versioning.

 

What Is a Content Management System?


The exact definition of a CMS is somewhat slippery, as the range of CMS systems is broad and the functionalities of each differ markedly. At the core, however, a content management system provides a framework for creating, managing, and publishing documents and texts. In more practical terms, a content management system handles the process of creating and maintaining a collection (large or small) of documents.

While CMS systems in general deal with a wide variety of types of collections, ranging from memos to marketing material, web-based collections are the most high profile. To that end, many CMS systems, including OpenCms, focus on web-based management (also called Web Content Management or WCM) and delivery of content.

Three Essential Components

There are three essential components to an enterprise-class CMS:

  • Editorial workflow

  • Publishing

  • Versioning

Editorial workflow refers to the process of preparing a piece of content for production. In the simplest case, this may simply involve one person writing a document, proofing it, and perhaps also revising it. However, in a larger context, the process may involve multiple authors writing content that is then edited by a team of editors and producers. A manager may assign a topic to an individual author who then writes a document. Once the author is done with the document, a team of editors reviews and corrects it, occasionally handing it back to the author for revision. Once this iterative process is complete, the editors submit the document to a producer, who makes decisions about whether the content is to be distributed, and if so, when. A good CMS must handle both the simple and the complex cases of editing. Once a document is written, it must be published.

Publishing is the next step in the life of the document. Publishing the document makes it accessible to potential readers. Some collections of content, such as the numerous chapters in a manual, are all published together. Other content, such as a news article or a press release, may be published on its own without requiring simultaneous publishing of other material. Sometimes images need to be published along with a particular document. Sometimes the document may require a certain amount of dynamic information (such as stock quotes or live images) to be incorporated. All of these possibilities mandate an effective publishing mechanism. A document's life cycle is not complete once it's published—it now enters version control.

Versioning becomes important once a document has been published. Authors and editors may make corrections or add updated information, and these changes may require their own editorial cycle before they can be published. Changes to the document should not be immediately incorporated into the published version, but must remain in the editorial stage while the currently published version remains available. Even after the changes are published, circumstances may require that the update be 'backed out' and the prior version restored. This process of revising and updating a document while preserving a record of changes is called versioning.

 

What Is OpenCms?


OpenCms is an open-source enterprise-grade content management system designed specifically for maintaining websites. It provides a full set of tools for dealing with content creation, editorial workflow, publishing, and versioning.

OpenCms is released under the Lesser GNU Public License (LGPL), which is an Open Source Initiative (OSI) certified open-source license created by the Free Software Foundation. Since OpenCms is released as open source, its source code is available from the OpenCms website.

The LGPL dictates that the source code for OpenCms must be made freely available. The source code for any changes made to it must also be made freely available.

However, external components, such as modules, wrappers, or JSP files, are not restricted by the LGPL, and can use different licenses (including proprietary, 'closed-source' licenses). This gives the application developer the power to decide how many restrictions should be placed on the code.

Features

OpenCms is a web application. It runs on a web server and is accessed and used via a web browser. The following list discusses its features:

  • Browser-based interface: The only tool CMS users need, be they system administrators, authors, editors, or project managers, is a web browser. The OpenCms developers designed OpenCms to behave in a way similar to a normal Windows application, making it easier for the beginner to learn.

  • WYSIWYG editing tool: Authors and editors need not learn HTML to create content. OpenCms uses an ActiveX control to provide a rich graphical user interface (GUI) for composing content (effectively limiting the WYSIWYG editor to IE5+ browsers). Users familiar with word processing should easily acclimate to the OpenCms composer.

  • Role-based workflow: OpenCms has a sophisticated role-based workflow for managing the entire process of content creation.

  • Permissions model: Using a combination of UNIX-like permissions and roles, OpenCms provides methods for setting and restricting assets available to CMS users.

  • Sophisticated publishing: OpenCms provides project and file-based publishing. Additionally, it performs link and dependency checking to ensure that all of the necessary files are published together. Content can be exported from the CMS and deployed on other systems, or OpenCms itself can serve content to the public.

  • System administration: OpenCms administration is also browser-based. Tasks ranging from scheduling tasks to manually flushing caches can be done via the browser.

  • Online help: Open-source projects are often criticized for the lack of documentation. OpenCms, however, does not suffer from that problem. While the help module is optional, it provides context-sensitive help throughout OpenCms. Additionally, there are tutorial modules that can provide developer help and reference within OpenCms.

  • Module-based framework: OpenCms provides a module mechanism for adding functionality to the system. Modules ranging from online documentation (tutorials and references) to advanced content handling (calendars, news, search engines, etc.) are available as add-on software.

History

Alexander Kandzior began tinkering with content management software in 1994. By 1998, the pieces began to come together into a single content management system. In March 2000, the OpenCms Group, a loose collection of individuals working on the system, released OpenCms under an open-source license.

Under the auspices of the OpenCms Group, a number of companies and individuals contributed to the formation of OpenCms, but by the time OpenCms reached version 5.0 in 2002, some of the original members of the group were ready to move on to new projects. The OpenCms Group was dissolved.

Wanting to continue the development of his code, Alexander Kandzior started a new company, Alkacon Software, which took the reins of the OpenCms project. Alkacon Software now maintains the project, providing the roadmap and release cycle, as well as contributing code to OpenCms. To fund ongoing development of OpenCms, Alkacon provides support contracts, training, and consulting services.

Alexander and the Alkacon team are a visible presence in the community, and Alexander often contributes help and advice on the public OpenCms developer's list.

The OpenCms Community

Like many open-source projects, OpenCms has a lively community of developers and users. Many software developers contribute code directly to OpenCms. Others create add-on modules to provide additional services and features. Many more simply use the product. All three of these groups participate on mailing lists and forums surrounding OpenCms.

With many active contributors, the opencms-dev mailing list is a great resource for help installing, configuring, and developing OpenCms. In addition to providing help, the list is also a useful source of code and new modules.

Also, the 'unofficial' OpenCms forums hosted by Synyx oHG provides an online forum for discussion. The forum has a section for HowTos, and sample code generated by members of the community. Finally, the OpenCms Modules and Tutorials section mentions the al-arenal.de website. While OpenCms.org hosts completed modules on its website, developers will often release beta modules, modifications of existing modules, and 'semi-formal' documentation on this unofficial OpenCms website.

 

The Purpose of This Book


This book is intended to provide detailed information for those interested in developing and deploying OpenCms-based sites. It is assumed that the reader is familiar with installing software and managing either Windows 2000 or Linux/UNIX. Because much of this book is dedicated to writing HTML, Java Server Pages, and Java code, having a working knowledge of these technologies is necessary.

 

Technical Overview


OpenCms is written in Java. It makes use of industry-standard XML (eXtensible Markup Language), and uses Java DataBase Connectivity (JDBC) to store data in a relational database. Built in Java, OpenCms can run on different platforms, including numerous versions of UNIX and Linux, and Windows.

Hardware-wise, OpenCms is designed for scalability. It will run on hardware ranging from small laptops (I've run it on a Pentium III 733 Toshiba Tecra laptop with 256 MB RAM and Red Hat 8) to a distributed collection of servers.

Being a web-based application, OpenCms runs as a Java servlet inside a servlet container such as Apache Tomcat or BEA WebLogic. For data storage, it can use a number of SQL databases, including MySQL, Microsoft SQL Server, and Oracle.

At one time, OpenCms required developers to learn a proprietary XML schema for developing templates, but in version 5.0, OpenCms has changed direction and now uses Java Server Pages; we'll get into the details of the system later. Here is a brief summary of how each of these components works (and how they all work together).

The Web Server and Java Servlets

The web server handles incoming connections. As it sees connections intended for OpenCms, it hands them off to the servlet container for processing. The servlet container manages one or more Java servlets. Unlike a CGI script, which runs only for the amount of time it takes to process a single request, a servlet stays running until the server explicitly stops it (which usually only happens when the server shuts down). The job of the servlet container is to provide the runtime environment for the servlets.

While it is possible to run OpenCms on the command line, it is almost always run as a servlet.

The Database

OpenCms uses a database for persistent data storage. Information about file types, templates, and publishing is stored in the database, as is all the content. OpenCms supports a couple of major SQL-based databases, including MySQL, Microsoft SQL Server, and Oracle. Developers are working on ports to PostgreSQL and other databases.

OpenCms uses JDBC to connect the Servlet to the database during startup. Content is managed inside the database, though it can be exported from the database into static files during a publishing cycle.

Pages, Templates, and Java Server Pages

Content is stored in the database in the form of XML files. Layout information and processing code is also stored in the database, but not in the same XML document as the content. When a page is requested, the content is pulled out of the database and put into a template. Any special processing needed is run, and the results are sent back to the requester (usually a web browser) in the form of a complete HTML file.

Templates and custom code are written in two languages: XML Template, a simple XML-based language developed by the OpenCms team, and Java Server Pages, a standardized language for embedding Java processing instructions inside of an HTML or XML document. While XML Template is still used in OpenCms 5, it will be phased out and replaced by the more flexible and mature JSP technology in future releases.

Bringing it Together

Each of these pieces functions together for each request. A typical response to a document (we'll call it test.html) might look like this:

  1. 1. The web browser requests test.html.

  2. 2. The web server recognizes that the request must be handled by OpenCms; it passes it off to the OpenCms Servlet request handler.

  3. 3. OpenCms retrieves information about test.html (including the content) from the database.

  4. 4. OpenCms puts the content for test.html into its template, adding all of the necessary layout elements and interpreting any JSP or XML template code that it needs for fulfilling the request.

  5. 5. Once OpenCms has created the complete HTML document, the document is returned to the browser.

  6. 6. The web browser interprets the HTML, runs any JavaScript that it finds, and displays the test.html page.

 

Summary


By now, you should be familiar with the basics of OpenCms—its uses, history, and key components. The next chapter will cover the installation of OpenCms, and subsequent chapters will discuss the use of and development on OpenCms.

About the Author

  • Matt Butcher

    Matt is a web developer and author. He has previously written five other books for Packt, including two others on Drupal. He is a senior developer for the New York Times Company, where he works on ConsumerSearch.com, one of the most traffic-heavy Drupal sites in the world. He is the maintainer of multiple Drupal modules and also heads QueryPath – a jQuery-like PHP library. He blogs occasionally athttp://technosophos.com.

     

    Browse publications by this author
Book Title
Unlock this full book FREE 10 day trial
Start Free Trial