vrijdag 22 augustus 2014

Getting the Alfresco version number programmatically

When you create an add-on to Alfresco you often want to ensure compatibility with multiple versions of Alfresco. To do this it is useful to have access to the version number of the current Alfresco server.

Here are three ways:

JavaScript

In server-side JavaScript you can use the server object.

server.version
server.versionMajor
server.versionMinor
server.versionRevision
server.edition

Java

In Java code you need to call the DescriptorService. This rarely used service allows you to access three descriptors

  1. descriptorService.getCurrentRepositoryDescriptor()
    The current repository descriptor. This information is stored in a hidden node inside the repository.
  2. descriptorService.getServerDescriptor()
    The server descriptor: this is the version of the software currently running. This should match the version of the current repository except during an upgrade.
  3. descriptorService.getInstalledRepositoryDescriptor()
    The installed Repository Descriptor: this is the version information of the repository when it was first installed, also stored as a hidden node in the repository.

The Descriptor object returned by these methods allows you to access the version number (major, minor and revision), edition (community or enterprise) and database schema version.

REST API

The third way is using the Alfresco REST API. This is needed for client applications not running inside Alfresco. Also JavaScript running in the browser as part of Share or a third-party web application can use this.

The endpoint to call is

http://<host>:<port>/alfresco/api/server

or via the Share proxy

http://<host>:<port>/share/proxy/alfresco/api/server

This returns a JSON object containing the version number, edition and schema version


{
   data: {
      edition: "Enterprise",
      version: "5.0.0",
      schema: "8002"
   }
}

zondag 13 mei 2012

5 Steps to Alfresco development using Jeff Pott's Alfresco Developer Series Tutorials

If you're new to Alfresco development it can be difficult to know where to begin. There is a lot of information in the wiki and the forums but these are not the step-by-step guides you need to get started quickly.

One of the best resources to start are Alfresco community manager Jeff Pott's tutorials. These well written tutorials cover the most important extension points of the Alfresco document repository. After reading them you will know the basics to start a successful Alfresco project.

Most of these tutorials were updated recently to cover the latest Alfresco versions.


Step 1: Defining the content model

The first step in every Alfresco project is defining a content model. The content model is a list of content types and their corresponding metadata fields.

Working with Custom Content Types teaches you to create a content model, expose the model in the Share UI, performing searches and doing CRUD operations against your custom content types.

The other articles in the series build on the examples included here.


Step 2: Extending the Repository: Behaviours and Actions

Next up are actions and behaviors. These make your content model come alive.

Actions let you encapsulate an operation on the repository so it can be executed from a rule, from custom Java or Javascript code or remotely using the web services API.

Behaviors are a way to couple behavior to your custom content types, if you want to trigger some code on creation or update of a document this is the way to go. You could say behaviors are an advanced version of rules.


Step 3: Web Scripts

Web Scripts allow you to extend Alfresco with your own RESTful API. Common use cases are creating a simple form, administration tool or custom view or to integrate with other applications. They are also used extensively inside to Alfresco Share UI.

Intro to the Web Script Framework

Step 4: Workflow

Content is almost always created or used in the context of a business process. In this tutorial Jeff explains how to implement content-based business processes by leveraging the Alfresco Activiti workflow engine. 

Activiti was created by the jBPM developers and supports the BPMN 2.0 standard.


Step 5: Integrating with Alfresco: the CMIS Web Services

The last step  in this series is CMIS. CMIS is a standard for accessing Enterprise Content Management systems like Alfresco. It is the recommended way to access content that's stored inside Alfresco form external applications.

There are two implementations: the SOAP web services and the AtomPub RESTful API. Alfresco supports both.

Getting Started with CMIS


The book

Because of the success of these tutorials they were reworked and published in the excellent book titled the Alfresco Developer Guide. If you want to learn more or just prefer a paper version over online tutorials this book is highly recommended!

Buy the book on Amazon (support this site by using the link below):


Alfresco Developer Guide



What's next?

The Alfresco Developer Series focuses on the Alfresco repository. Most projects require more extensive customization and extension of the Alfresco Share UI which is not really dealt with in these tutorials. I will cover this in a later article.

Subscribe to this blog so you don't miss the next post.