·¬ÇÑÉçÇø

Brightspot CMS Developer Guide

Controlling revision access


Revisions are a helpful method of branching off from the published version of an asset, making changes, and then preserving those changes without publishing them live until a specified time in the future; however, by default, there is no restriction on who can create revisions, and the only way to access revisions is from the Version History widget on the content edit page (formerly referred to as the Revisions widget in Brightspot versions prior to 4.8). Because this may not always be desirable, Brightspot lets you control revision access.

Reasons you may want to limit revision access or to present only the latest revision:

  • A new editor might only be required to perform simple functions in Brightspot, like proofreading the asset, but is not allowed to take editorial actions like creating a revision. Giving this individual the ability to create a revision can complicate operations or be superfluous to their needs.
  • An editor working too quickly may not refer to the Version History widget and instead publish a change to the live asset. The revision author must then reconcile the published changes with those in the revision, which is time-consuming and prone to errors.
  • An asset has multiple reviewers, all of whom must navigate to the asset, then select the appropriate revision. The extra clicks add up over time and unnecessarily increase the asset's workflow life cycle.
Note
While this topic describes revisions and their access, the name of the data model object that is used to store a revision is Draft.java. This should not be confused with the drafts feature in Brightspot, which refers to content that is saved but not yet published.


The DraftAccess.java and DraftSelector.java ClassFinder-based APIs allow administrators to set and enforce these controls so that an editor has a more curated experience in Brightspot.

DraftAccess API

DraftAccess.java determines whether or not a revision can be created.

interface DraftAccess<T extends Recordable> {
    boolean isCreationAllowed(T content);
}

DraftSelector API

DraftSelector.java determines whether or not, when visiting an asset's content edit form, the latest revision of an asset is presented instead of the published version.

interface DraftSelector<T extends Recordable> {
    Draft selectDraft(T content);
}

Example

In the following code snippet, an editor navigating to an asset lands immediately on the existing revision of it and cannot create any other revisions from it.

import com.psddev.cms.db.Content;
import com.psddev.cms.db.Draft;
import com.psddev.cms.ui.content.DraftAccess;
import com.psddev.cms.ui.content.DraftSelector;
import com.psddev.dari.db.Query;

public class ExampleRevisionManager implements DraftAccess<Content>, DraftSelector<Content> {

    // only allow creation of new revisions if there are no existing revisions for the given content
    @Override
    public boolean isCreationAllowed(Content content) {
        return !Query.from(Draft.class)
            .where("objectId = ?", content.getId())
            .hasMoreThan(0);
    }

    // when the given content is accessed, direct the user to the one existing revision instead
    @Override
    public Draft selectDraft(Content content) {
        return Query.from(Draft.class)
            .where("objectId = ?", content.getId())
            .first();
    }
}


As a result of this code, the editor sees a Revisions widget without the option to Start New Revision.
As a result of this code, in the Revisions widget, the editor is routed directly to the latest revision of the asset, and not to the published version.

Previous Topic
Editorial content report APIs
Next Topic
Dari guide
Was this topic helpful?
Thanks for your feedback.
Our robust, flexible Design System provides hundreds of pre-built components you can use to build the presentation layer of your dreams.

•
•
•
Brightspot is packaged with content types that get you up and running in a matter of days, including assets, modules and landing pages.

• Content types
• Modules
• Landing pages
Everything you need to know when creating, managing, and administering content within Brightspot CMS.

• Dashboards
• Publishing
• Workflows
• Admin configurations
A guide for installing, supporting, extending, modifying and administering code on the Brightspot platform.

• Field types
• Content modeling
• Rich-text elements
• Images
A guide to configuring Brightspot's library of integrations, including pre-built options and developer-configured extensions.

• Google Analytics
• Shopify
• Apple News