Features

Features are aspect-oriented, cross-cutting concerns that can be applied to nodes. Once applied, they may introduce new behaviors and metadata to your content objects. You can use features to describe cross-cutting or aspect-oriented concerns that can be plugged onto your content nodes at any time. Features may participate in the inheritance tree of content types or they may be injected anywhere and at any point.

There are a number of out-of-the-box features provided by Cloud CMS, including:

  • Watermarkable - a content node's binary attachment should automatically be watermarked
  • Multilingual - a content node supports localized text and delivery
  • Audit - a content node's method calls and interactions should be recorded in an audit log. This lets you then later retrieve the audit log for use in asserting compliance with regulatory requirements.
  • Geolocation - a content node supports geolocation indexing (lat and long)
  • Thumbnailable - a content node's binary attachment should be thumbnailed to various sizes. This is often used for rendering thumbnails on different form factors (iPhone, iPad, various Android devices, etc).

There are many others. In addition, you can define your own. Feature definitions are simply JSON documents that you upload or create. You can create them at will within the Cloud CMS user interface.

Features (Out-of-the-box)

The following features are provided by default. You can use these right away within your content models:

Adding Features to your Content Instances

To add a feature to your content instances, you simply plug in the relevant JSON to the _features section of the JSON.

For example, let's imagine I have an article that looks like this:

{
    "title": "Brewers finish season in 3rd place",
    "body": "The Milwaukee Brewers finished the 2014 baseball season with a record of 82-80."
}

To make the article generate an audit log of all of its operations, all I need to do is add the f:auditable feature to the node. I can do that by modifying the JSON to accommodate the following:

{
    "title": "Brewers finish season in 3rd place",
    "body": "The Milwaukee Brewers finished the 2014 baseball season with a record of 82-80.",
    "_features": {
        "f:auditable": {
        }
    }
}

The presence of the f:auditable key in the _features block informs Cloud CMS that the content node should take on the behaviors or metadata prescribed by the Auditable feature. In this case, the Auditable feature is a feature that is provided out of the box. It does not prescribe new metadata but it does plug in interceptors to all of the future operations that may occur against node so that those operations can be logged and reported on.

Adding Features to your Content Type Definitions

You can also add mandatory features to your content type definitions. Mandatory features are features that any content instances of a given type will automatically inherit. By marking a content type as having a feature, all content instances of that type will also have the feature.

Let's imagine we define an Article content type called custom:article. It might look like this:

{
    "_qname": "custom:article",
    "type": "object",
    "properties": {
        "title": {
            "title": "Title",
            "type": "string"
        },
        "body": {
            "title": "Body",
            "type": "string"
        }
    }
}

Let's now define a custom feature. In the last example, we used an out-of-the-box feature. In this example, let's create a new feature called custom:authorable. Any content stamped with our Authorable feature will have an author property.

The feature definition might look like this:

{
    "_qname": "custom:authorable",
    "type": "object",
    "properties": {
        "author": {
            "title": "Author",
            "type": "string",
            "minLength": 3,
            "maxLength": 20
        }
    }
}

This feature definition is a pretty simple one. It describes a feature that endows any content with an additional property called author. The author property has a minimum length of 3 and a maximum length of 20.

And now let's update our custom:article content type so that the custom:authorable feature is mandatory.

{
    "_qname": "custom:article",
    "type": "object",
    "properties": {
        "title": {
            "title": "Title",
            "type": "string"
        },
        "body": {
            "title": "Body",
            "type": "string"
        }
    },
    "mandatoryFeatures": {
        "f:auditable": {
        }
    }
}

Once we've done this (and saved our changes), Cloud CMS automatically recompiles the data dictionary and gives us validation and behavior for our articles which includes the new feature. We can create our content instance and have it validate with the new author field. The content instance might look like this:

{
    "_type": "custom:article",
    "title": "Brewers finish season in 3rd place",
    "body": "The Milwaukee Brewers finished the 2014 baseball season with a record of 82-80.",
    "author": "Bob Uecker"
}

By indicating its type, Cloud CMS will automatically apply all validation logic for content types, inherited types and the cross-cutting concerns of any features you apply at the instance or type level.

Features

In this section, we'll look at the out-of-the-box features provided by Cloud CMS and provide examples of how to set these up onto your own content objects.

All features can be enabled or disabled by specifying an enabled property in the feature configuration. If not provided, the feature is assumed to be active.