Search in sources :

Example 1 with SiteDiscriminator

use of org.broadleafcommerce.common.extensibility.jpa.SiteDiscriminator in project BroadleafCommerce by BroadleafCommerce.

the class AdminNavigationServiceImpl method buildAuthorizedSectionsList.

protected List<AdminSection> buildAuthorizedSectionsList(AdminUser adminUser, AdminModule module) {
    List<AdminSection> authorizedSections = new ArrayList<AdminSection>();
    BroadleafRequestContext broadleafRequestContext = BroadleafRequestContext.getBroadleafRequestContext();
    Site site = broadleafRequestContext.getNonPersistentSite();
    Long siteId = site == null ? null : site.getId();
    for (AdminSection section : module.getSections()) {
        if (isUserAuthorizedToViewSection(adminUser, section)) {
            if (section instanceof SiteDiscriminator) {
                Long sectionSiteId = ((SiteDiscriminator) section).getSiteDiscriminator();
                if (sectionSiteId == null || sectionSiteId.equals(siteId)) {
                    authorizedSections.add(section);
                }
            } else {
                authorizedSections.add(section);
            }
        }
    }
    Collections.sort(authorizedSections, SECTION_COMPARATOR);
    return authorizedSections;
}
Also used : Site(org.broadleafcommerce.common.site.domain.Site) SiteDiscriminator(org.broadleafcommerce.common.extensibility.jpa.SiteDiscriminator) AdminSection(org.broadleafcommerce.openadmin.server.security.domain.AdminSection) BroadleafRequestContext(org.broadleafcommerce.common.web.BroadleafRequestContext) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 SiteDiscriminator (org.broadleafcommerce.common.extensibility.jpa.SiteDiscriminator)1 Site (org.broadleafcommerce.common.site.domain.Site)1 BroadleafRequestContext (org.broadleafcommerce.common.web.BroadleafRequestContext)1 AdminSection (org.broadleafcommerce.openadmin.server.security.domain.AdminSection)1