use of org.broadleafcommerce.openadmin.server.security.domain.AdminSection 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;
}
use of org.broadleafcommerce.openadmin.server.security.domain.AdminSection in project BroadleafCommerce by BroadleafCommerce.
the class AdminNavigationServiceImpl method getClassNameForSection.
@Override
public String getClassNameForSection(String sectionKey) {
AdminSection section = findAdminSectionByURI("/" + sectionKey);
ExtensionResultHolder erh = new ExtensionResultHolder();
extensionManager.getProxy().overrideClassNameForSection(erh, sectionKey, section);
if (erh.getContextMap().get(AbstractAdminAbstractControllerExtensionHandler.NEW_CLASS_NAME) != null) {
return (String) erh.getContextMap().get(AbstractAdminAbstractControllerExtensionHandler.NEW_CLASS_NAME);
}
return (section == null) ? sectionKey : section.getCeilingEntity();
}
use of org.broadleafcommerce.openadmin.server.security.domain.AdminSection in project BroadleafCommerce by BroadleafCommerce.
the class AdminNavigationServiceImpl method populateAdminMenu.
protected void populateAdminMenu(AdminUser adminUser, AdminMenu adminMenu, List<AdminModule> modules) {
for (AdminModule module : modules) {
List<AdminSection> authorizedSections = buildAuthorizedSectionsList(adminUser, module);
if (authorizedSections != null && authorizedSections.size() > 0) {
AdminModuleDTO adminModuleDto = ((AdminModuleImpl) module).getAdminModuleDTO();
adminMenu.getAdminModules().add(adminModuleDto);
adminModuleDto.setSections(authorizedSections);
}
}
// Sort the authorized modules
BeanComparator displayComparator = new BeanComparator("displayOrder");
Collections.sort(adminMenu.getAdminModules(), displayComparator);
}
use of org.broadleafcommerce.openadmin.server.security.domain.AdminSection in project BroadleafCommerce by BroadleafCommerce.
the class AdminSectionHrefProcessor method getModifiedAttributes.
@Override
public BroadleafAttributeModifier getModifiedAttributes(String tagName, Map<String, String> tagAttributes, String attributeName, String attributeValue, BroadleafTemplateContext context) {
String href = "#";
AdminSection section = (AdminSection) context.parseExpression(attributeValue);
if (section != null) {
HttpServletRequest request = BroadleafRequestContext.getBroadleafRequestContext().getRequest();
href = request.getContextPath() + section.getUrl();
}
Map<String, String> attrs = new HashMap<>();
attrs.put("href", href);
return new BroadleafAttributeModifier(attrs);
}
use of org.broadleafcommerce.openadmin.server.security.domain.AdminSection in project BroadleafCommerce by BroadleafCommerce.
the class AdminBasicEntityController method viewCollectionItemDetails.
/**
* Shows the modal popup for the current selected "to-one" field. For instance, if you are viewing a list of products
* then this method is invoked when a user clicks on the name of the default category field.
*
* @param request
* @param response
* @param model
* @param pathVars
* @param collectionField
* @param id
* @return
* @throws Exception
*/
@RequestMapping(value = "/{collectionField:.*}/{id}/view", method = RequestMethod.GET)
public String viewCollectionItemDetails(HttpServletRequest request, HttpServletResponse response, Model model, @PathVariable Map<String, String> pathVars, @PathVariable(value = "collectionField") String collectionField, @PathVariable(value = "id") String id) throws Exception {
String sectionKey = getSectionKey(pathVars);
String mainClassName = getClassNameForSection(sectionKey);
List<SectionCrumb> sectionCrumbs = getSectionCrumbs(request, sectionKey, id);
ClassMetadata mainMetadata = service.getClassMetadata(getSectionPersistencePackageRequest(mainClassName, sectionCrumbs, pathVars)).getDynamicResultSet().getClassMetaData();
Property collectionProperty = mainMetadata.getPMap().get(collectionField);
BasicFieldMetadata md = (BasicFieldMetadata) collectionProperty.getMetadata();
AdminSection section = adminNavigationService.findAdminSectionByClassAndSectionId(md.getForeignKeyClass(), sectionKey);
String sectionUrlKey = (section.getUrl().startsWith("/")) ? section.getUrl().substring(1) : section.getUrl();
Map<String, String> varsForField = new HashMap<>();
varsForField.put("sectionKey", sectionUrlKey);
return viewEntityForm(request, response, model, varsForField, id);
}
Aggregations