A note from 2026: This article was published in 2016 and targets the legacy hybris WCMS Cockpit/JSP Accelerator stack. SAP Commerce Cloud has since moved away from the hybris branding, Cockpit Framework tools have been deprecated in favor of Backoffice and SmartEdit, and many storefronts now use SAP Composable Storefront instead of JSP-based templates.

Situation

There are two ways to implement this partially:

Complexity

Although the data model supports multiple content catalogs assigned to a single website (CMSSite), the cockpit itself is not ready. For a single content catalog, out-of-the-box hybris doesn’t have any capability to hide a particular content slot from users who don’t have sufficient permissions to manage it.

Challenge

Hide particular content slots in hybris WCMS, depending on the current administrator’s rights.

Multi-country content catalog structure

Solution

Technical solution

Architecture

WCMS part

There is an “interceptor” — the hybris layer between the model class and the service class. This interceptor replaces slot names on the fly.

Sequence diagram of WCMS-LoadInterceptor interaction

Sequence diagram of WCMS-LoadInterceptor interaction

Storefront part

The Page Controller or Filter should set a variable, “region”, and push it into JSP.

JSP’s pageSlot tag has an attribute, “position”. In our solution, we will build the value of the “position” attribute dynamically using the value of the “region” variable.

Storefront regional content slots

PageTemplateModel.onLoad Interceptor

public class LoadVelocityTempateInterceptor implements LoadInterceptor<PageTemplateModel> {

    @Resource
    UserService userService;

    @Resource
    SessionService sessionService;

    @Resource
    CMSSiteService cmsSiteService;

    @Override
    public void onLoad(PageTemplateModel o, InterceptorContext var2) throws InterceptorException
    {
        // check if the request is from backoffice (WCMS)
        if (cmsSiteService.getCurrentSite() != null) { return; }

        String vt = o.getVelocityTemplate();
        UserModel currentUser = userService.getCurrentUser();
        Set<UserGroupModel> groups = userService.getAllUserGroupsForUser(currentUser);
        Iterator<UserGroupModel> iter = groups.iterator();

        while (iter.hasNext()) {
            UserGroupModel ugm = iter.next();
            String groupStr = ugm.getUid();

            if (groupStr.indexOf("reg_") != -1) {
                vt = vt.replace("_regional_", "_reg_" + groupStr);
                o.setVelocityTemplate(vt);
                return;
            }
        }
    }
}

Page Controller

...
model.addAttribute("regional", AreWeOnCanadianWebsite() ? "reg_ca" : "reg_us");
...

JSP template

JSP template regional slot example

Velocity Template (for WCMS)

Velocity template regional slot example

© Rauf Aliev, June 2016