Reader small image

You're reading from  Alfresco One 5.x Developer???s Guide - Second Edition

Product typeBook
Published inFeb 2017
Reading LevelBeginner
PublisherPackt
ISBN-139781787128163
Edition2nd Edition
Languages
Concepts
Right arrow
Authors (2):
Benjamin Chevallereau
Benjamin Chevallereau
author image
Benjamin Chevallereau

Benjamin Chevallereau is a French software architect, based in London, who has been working on Alfresco projects for the last 8 years and Ephesoft projects for the last 3 years. He implemented solutions for small companies and global organizations in different domains such as transport, finance, and government. He has worked for different Alfresco-recognized partners in France, the UK, and USA, including Armedia LLC, Zaizi, Michelin / Wipro, and BlueXML. He is also one of the committers and PMC members of the Apache CMIS Chemistry project.
Read more about Benjamin Chevallereau

Jeff Potts
Jeff Potts
author image
Jeff Potts

Jeff Potts is the founder of Metaversant Group, Inc., a consulting firm focused on content management, search, and workflow. Jeff brings over 20 years of Enterprise Content Management implementation experience to organizations of all sizes including the Fortune 500. Throughout his consulting career he has worked on a number of projects for clients across the media and entertainment, airline, consumer packaged goods, and retail sectors. Jeff began working with and blogging about Alfresco in November of 2005. In 2006 and 2007, he published a series of Alfresco tutorials and published them on his blog, ecmarchitect.com. That work, together with other Community activity in Alfresco's forum, Wiki site, and JIRA earned him Alfresco's 2007 Community Contributor of the Year Award. In the past, Mr. Potts has worked for Alfresco Software, Inc. as Chief Community Officer, Optaros as Senior Practice Director, and Hitachi Consulting as Vice President where he ran the ECM practice.
Read more about Jeff Potts

View More author details
Right arrow

Chapter 2. Getting Started with Alfresco

Before you can customize Alfresco, you need to get your development environment in order. In this chapter, you'll learn how to install the software development kit (SDK), how to build and deploy customizations, helpful debugging tips, and the cleanest and quickest way to reset your Alfresco sandbox. The chapter includes an example that shows how to package and deploy some extremely basic customizations just to get your feet wet. Specifically, you are going to learn:

  • How to install Alfresco on your environment

  • How to install and configure the software on which the SDK depends

  • How to extend Alfresco without modifying the Alfresco source code or configuration

  • How to package and deploy your customizations

  • How to use the Eclipse debugger and log4j to troubleshoot problems

  • How to start clean for testing or debugging purposes

This book will help you how to install Alfresco on your local by creating a virtual machine to host Alfresco. There are a lot of options...

Introduction to the Alfresco SDK


Alfresco is providing its SDK as a Maven based development kit. It provides a quick and easy approach to develop your own Alfresco extensions. You can use this SDK in any integrated development environment (IDE), and even in the console. However, we'll use Spring Tool Suite (STS) in this chapter. With this SDK you can develop, package, test, run, document and release your Alfresco extension project. It is important to note that while previous versions of the Alfresco SDK were based around Ant, the latest versions of the SDK are based on Maven.

The Alfresco SDK includes three different Maven archetypes described below. These archetypes aim to provide a standardized approach to development, release, and deployment of Alfresco extensions.

Maven archetypes

There are three Maven archetypes that can be used to generate Alfresco extension projects. The following project types, and archetypes, are available:

  • Alfresco Repository AMP: This archetype is used to create...

Create your first application


We'll first discover how we can use the Maven SDK and RAD to quickly create your own application. Even if we'll explore this option, we won't use it in the rest of the book. We'll use a more traditional approach that you'll be able to re-use in your own Alfresco projects.

Rapid application development

In this section, we'll take a small detour to talk about rapid application development. As explained before, Alfresco SDK provides three different archetypes. One of them is called the Alfresco AIO archetype. Using this archetype, you can easily implement all your customization in a unique STS project and run the full Alfresco platform. It means that you don't need to install Alfresco on your system and it provides a perfect starting point for full-blown Alfresco projects where the final artifacts should be the customized alfresco.war and share.war.

In a typical project, you want to develop a reusable module that should be distributed independently. To achieve this...

Troubleshooting


There are three primary troubleshooting tools you will become intimately familiar with: Log4j, your favorite Java debugger, and the Alfresco Node Browser. There are other, less-frequently used tools and techniques that will be discussed when the time is right.

Log4j

Most of you are already familiar with this common logging tool, so not a lot of discussion is needed. For everyone else, here are the basics. The verbosity of the log output, the specific classes being logged, and other logging settings are controlled by Log4J property file:

If you are looking at a temporary change, you can update the file custom-log4j.properties in the directory <TOMCAT_HOME>|shared|classes|alfresco|extension.

  • Don't forget the JMX option. The JMX interface allows to access Alfresco Enterprise via a standard JMX console that supports JMX Remoting (JSR-160). It's a very useful tool to perform on-demand change at runtime without needing to restart the server.

  • If you are looking for a more permanent...

Starting over


During development, it is quite common to have to start with a fresh repository. Usually this is because you've made a significant change to the model, and you'd rather blow everything away than clean up inconsistencies. The Alfresco repository is made up of three parts: the metadata stored in the relational database, the binary files stored on the file system and the Solr indexes. To clear out the repository, you have to clear out all three. If you delete the data directory but not the database, you will see a bunch of data integrity problems because the binary files that the database knows about are no longer there. Be sure that Alfresco is stopped.

Let's start by the database:

  1. Start PostgreSQL: service alfresco start postgresql

  2. Recreate the database:

            /opt/alfresco/postgresql/bin/psql -U postgres 
            Password for user postgres: admin 
            postgres=#DROP DATABASE alfresco; 
            postgres=#CREATE DATABASE alfresco WITH OWNER alfresco; 
    ...

Summary


This chapter was about getting your development environment ready to go, providing an overview of how the platform is extended, and understanding the debugging tools that are available. Specifically, you learned what is the Alfresco Maven SDK and which archetypes are available. We discovered how to install STS, and all-prerequisites to be able to use the Alfresco archetypes. Then, we did our first steps extending Alfresco without modifying Alfresco's source code or configuration. You learned the specific extension technique to use depending on the type of file being customized.

We learnt what to do when things inevitably go wrong. Familiar techniques such as log4j and remote debugging are available, just as they would be with any web application. In addition, the Node Browser can be a useful tool for inspecting the underlying data structure or testing out search queries.

And we terminated the chapter by understanding how to start clean for testing or debugging purposes. You learned...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Alfresco One 5.x Developer???s Guide - Second Edition
Published in: Feb 2017Publisher: PacktISBN-13: 9781787128163
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Benjamin Chevallereau

Benjamin Chevallereau is a French software architect, based in London, who has been working on Alfresco projects for the last 8 years and Ephesoft projects for the last 3 years. He implemented solutions for small companies and global organizations in different domains such as transport, finance, and government. He has worked for different Alfresco-recognized partners in France, the UK, and USA, including Armedia LLC, Zaizi, Michelin / Wipro, and BlueXML. He is also one of the committers and PMC members of the Apache CMIS Chemistry project.
Read more about Benjamin Chevallereau

author image
Jeff Potts

Jeff Potts is the founder of Metaversant Group, Inc., a consulting firm focused on content management, search, and workflow. Jeff brings over 20 years of Enterprise Content Management implementation experience to organizations of all sizes including the Fortune 500. Throughout his consulting career he has worked on a number of projects for clients across the media and entertainment, airline, consumer packaged goods, and retail sectors. Jeff began working with and blogging about Alfresco in November of 2005. In 2006 and 2007, he published a series of Alfresco tutorials and published them on his blog, ecmarchitect.com. That work, together with other Community activity in Alfresco's forum, Wiki site, and JIRA earned him Alfresco's 2007 Community Contributor of the Year Award. In the past, Mr. Potts has worked for Alfresco Software, Inc. as Chief Community Officer, Optaros as Senior Practice Director, and Hitachi Consulting as Vice President where he ran the ECM practice.
Read more about Jeff Potts