Support and Documentation

URL paths

Brightspot provides the Directory class for managing URL paths to Content-based objects stored in the database. Directory and its inner classes provide several APIs to support URL pathing.

Use Directory.Static.hasPathPredicate to verify that an object has a URL path, for example:

Query query = Query.from(Article.class).where("_id = '00000161-d80b-ddd6-a37d-fc3bb47a0000");
Article article = (Article) query.where(Directory.Static.hasPathPredicate()).first();
if (article == null) { /* Set a URL path */ }

Use Directory.ObjectModification#addPath to set a URL path on an object, for example:

Article article = new Article();
article.setHeadline("Hurricane-force Winds on Mt. Washington");
String path = StringUtils.toNormalized(article.getHeadline());, Directory.PathType.PERMALINK);

In the above snippet, the addPath method takes parameters for the URL path and the path type. The path is formed from the headline of the article, and the path type is specified with the Directory.PathType enumeration. PERMALINK is a link that never expires. See Asset-level URL management for a description of all URL options.

An object can have different paths for different sites. The addPath method creates a path for the site that owns the object. If you have multiple sites, you can use the addSitePath method to create a path that is associated with a specified site.

The following code extends the above example, adding the path before the object is saved. The addSitePath method creates a path to the object for a second site, News.

public void beforeSave() {
    List<Site> sites = Query.from(Site.class).selectAll();
    for (Site site : sites) {
        if (site.getName().equals("News")) {
            String path = StringUtils.toNormalized(this.getHeadline());
                     .addSitePath(site, "news//" + path, Directory.PathType.PERMALINK);


In order for an object's site-specified path to work, that site must be given access to the object; otherwise, the object is not visible to the site. For more information on site ownership and access, see Permissions and multiple sites.

The URLs widget in an object's content edit page shows assigned URL paths. For the article example, there is a path for the owner site, Global, and for a second site, News.

Auto-generate permalink

Brightspot provides the Directory.Item#createPermalink method to automatically generate permalinks for a specified site. For example, the following method implementation in the Article class creates a permalink for each instance of the class, based on the instance headline.

public String createPermalink(Site site) {
   return StringUtils.toNormalized(getHeadline());

Implementing createPermalink in a class is reflected in Brightspot. When you create an instance of the class, the Generate Permalink option appears in the URLs widget on the content edit page. Continuing with the Article class example, the permalink shown in the widget is based on a user-entered headline for the article.