use of org.broadleafcommerce.openadmin.server.security.domain.AdminSection in project BroadleafCommerce by BroadleafCommerce.
the class PersistencePackageFactoryImpl method getClassNameForSection.
protected String getClassNameForSection(String sectionKey) {
try {
AdminSection section = adminNavigationService.findAdminSectionByURI("/" + sectionKey);
String className = (section == null) ? sectionKey : section.getCeilingEntity();
if (className == null) {
throw new RuntimeException("Could not determine the class related to the following Section: " + section.getName());
}
SessionFactory sessionFactory = getEntityManager(className).unwrap(Session.class).getSessionFactory();
Class<?>[] entities = dynamicDaoHelper.getAllPolymorphicEntitiesFromCeiling(Class.forName(className), sessionFactory, true, true);
return entities[entities.length - 1].getName();
} catch (ClassNotFoundException e) {
throw ExceptionHelper.refineException(RuntimeException.class, RuntimeException.class, e);
}
}
use of org.broadleafcommerce.openadmin.server.security.domain.AdminSection in project BroadleafCommerce by BroadleafCommerce.
the class AdminNavigationDaoImpl method readAdminSectionByURI.
@Override
public AdminSection readAdminSectionByURI(String uri) {
Query query = em.createNamedQuery("BC_READ_ADMIN_SECTION_BY_URI");
query.setParameter("uri", uri);
query.setHint(org.hibernate.ejb.QueryHints.HINT_CACHEABLE, true);
query.setHint(QueryHints.HINT_CACHE_REGION, "blAdminSecurityQuery");
AdminSection adminSection = null;
try {
adminSection = (AdminSection) query.getSingleResult();
} catch (NoResultException e) {
// do nothing
}
return adminSection;
}
use of org.broadleafcommerce.openadmin.server.security.domain.AdminSection in project BroadleafCommerce by BroadleafCommerce.
the class AdminNavigationDaoImpl method readAdminSectionBySectionKey.
@Override
public AdminSection readAdminSectionBySectionKey(String sectionKey) {
Query query = em.createNamedQuery("BC_READ_ADMIN_SECTION_BY_SECTION_KEY");
query.setHint(org.hibernate.ejb.QueryHints.HINT_CACHEABLE, true);
query.setHint(QueryHints.HINT_CACHE_REGION, "blAdminSecurityQuery");
query.setParameter("sectionKey", sectionKey);
AdminSection adminSection = null;
try {
adminSection = (AdminSection) query.getSingleResult();
} catch (NoResultException e) {
// do nothing
}
return adminSection;
}
use of org.broadleafcommerce.openadmin.server.security.domain.AdminSection in project BroadleafCommerce by BroadleafCommerce.
the class AdminNavigationDaoImpl method readAllAdminSections.
@Override
public List<AdminSection> readAllAdminSections() {
Query query = em.createNamedQuery("BC_READ_ALL_ADMIN_SECTIONS");
query.setHint(org.hibernate.ejb.QueryHints.HINT_CACHEABLE, true);
query.setHint(QueryHints.HINT_CACHE_REGION, "blAdminSecurityQuery");
List<AdminSection> sections = query.getResultList();
return sections;
}
use of org.broadleafcommerce.openadmin.server.security.domain.AdminSection in project BroadleafCommerce by BroadleafCommerce.
the class AdminNavigationDaoImpl method readAdminSectionByClassAndSectionId.
@Override
public AdminSection readAdminSectionByClassAndSectionId(Class<?> clazz, String sectionId) {
String className = clazz.getName();
// Try to find a section for the exact input received
List<AdminSection> sections = readAdminSectionForClassName(className);
if (CollectionUtils.isEmpty(sections)) {
// Most of the sections should match to the interface
if (className.endsWith("Impl")) {
className = className.substring(0, className.length() - 4);
sections = readAdminSectionForClassName(className);
}
}
if (!CollectionUtils.isEmpty(sections)) {
AdminSection returnSection = sections.get(0);
if (sectionId == null) {
// if no sectionId was passed, ensure we are returning the correct section based on the request's sectionkey
sectionId = getSectionKey(true);
}
if (sectionId != null) {
if (!sectionId.startsWith("/")) {
sectionId = "/" + sectionId;
}
for (AdminSection section : sections) {
if (sectionId.equals(section.getUrl())) {
returnSection = section;
break;
}
}
}
return returnSection;
}
return null;
}
Aggregations