use of org.broadleafcommerce.common.exception.NoPossibleResultsException in project BroadleafCommerce by BroadleafCommerce.
the class PersistenceManagerImpl method fetch.
@Override
public PersistenceResponse fetch(PersistencePackage persistencePackage, CriteriaTransferObject cto) throws ServiceException {
for (PersistenceManagerEventHandler handler : persistenceManagerEventHandlers) {
PersistenceManagerEventHandlerResponse response = handler.preFetch(this, persistencePackage, cto);
if (PersistenceManagerEventHandlerResponse.PersistenceManagerEventHandlerResponseStatus.HANDLED_BREAK == response.getStatus()) {
break;
}
}
// check to see if there is a custom handler registered
for (CustomPersistenceHandler handler : getCustomPersistenceHandlers()) {
if (handler.canHandleFetch(persistencePackage)) {
if (!handler.willHandleSecurity(persistencePackage)) {
adminRemoteSecurityService.securityCheck(persistencePackage, EntityOperationType.FETCH);
}
DynamicResultSet results = handler.fetch(persistencePackage, cto, dynamicEntityDao, (RecordHelper) getCompatibleModule(OperationType.BASIC));
return executePostFetchHandlers(persistencePackage, cto, new PersistenceResponse().withDynamicResultSet(results));
}
}
adminRemoteSecurityService.securityCheck(persistencePackage, EntityOperationType.FETCH);
PersistenceModule myModule = getCompatibleModule(persistencePackage.getPersistencePerspective().getOperationTypes().getFetchType());
try {
DynamicResultSet results = myModule.fetch(persistencePackage, cto);
return executePostFetchHandlers(persistencePackage, cto, new PersistenceResponse().withDynamicResultSet(results));
} catch (ServiceException e) {
if (e.getCause() instanceof NoPossibleResultsException) {
DynamicResultSet drs = new DynamicResultSet(null, new Entity[] {}, 0);
return executePostFetchHandlers(persistencePackage, cto, new PersistenceResponse().withDynamicResultSet(drs));
}
throw e;
}
}
use of org.broadleafcommerce.common.exception.NoPossibleResultsException in project BroadleafCommerce by BroadleafCommerce.
the class CriteriaTranslatorImpl method determineRoot.
/**
* Determines the appropriate entity in this current class tree to use as the ceiling entity for the query. Because
* we filter with AND instead of OR, we throw an exception if an attempt to utilize properties from mutually exclusive
* class trees is made as it would be impossible for such a query to return results.
*
* @param dynamicEntityDao
* @param ceilingMarker
* @param filterMappings
* @return the root class
* @throws NoPossibleResultsException
*/
@SuppressWarnings("unchecked")
protected Class<Serializable> determineRoot(DynamicEntityDao dynamicEntityDao, Class<Serializable> ceilingMarker, List<FilterMapping> filterMappings) throws NoPossibleResultsException {
Class<?>[] polyEntities = dynamicEntityDao.getAllPolymorphicEntitiesFromCeiling(ceilingMarker);
ClassTree root = dynamicEntityDao.getClassTree(polyEntities);
List<ClassTree> parents = new ArrayList<ClassTree>();
for (FilterMapping mapping : filterMappings) {
if (mapping.getInheritedFromClass() != null) {
root = determineRootInternal(root, parents, mapping.getInheritedFromClass());
if (root == null) {
throw new NoPossibleResultsException("AND filter on different class hierarchies produces no results");
}
}
}
for (Class<?> clazz : polyEntities) {
if (clazz.getName().equals(root.getFullyQualifiedClassname())) {
return (Class<Serializable>) clazz;
}
}
throw new IllegalStateException("Class didn't match - this should not occur");
}
Aggregations