protected ContentPageModel getContentPageForLabelOrId(final String labelOrId)
      throws CMSItemNotFoundException {
    String key = labelOrId;
    if (StringUtils.isEmpty(labelOrId)) {
      // Fallback to site home page
      final ContentPageModel homePage = cmsPageService.getHomepage();
      if (homePage != null) {
        key = cmsPageService.getLabelOrId(homePage);
      } else {
        // Fallback to site start page label
        final CMSSiteModel site = cmsSiteService.getCurrentSite();
        if (site != null) {
          key = cmsSiteService.getStartPageLabelOrId(site);
        }
      }
    }

    // Actually resolve the label or id - running cms restrictions
    return cmsPageService.getPageForLabelOrId(key);
  }
 protected String getViewForPage(final AbstractPageModel page) {
   if (page != null) {
     final PageTemplateModel masterTemplate = page.getMasterTemplate();
     if (masterTemplate != null) {
       final String targetPage = cmsPageService.getFrontendTemplateName(masterTemplate);
       if (targetPage != null && !targetPage.isEmpty()) {
         return PAGE_ROOT + targetPage;
       }
     }
   }
   return null;
 }