use of org.broadleafcommerce.common.extension.ExtensionResultStatusType in project BroadleafCommerce by BroadleafCommerce.
the class BroadleafPageController method handleRequest.
@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
ModelAndView model = new ModelAndView();
PageDTO page = (PageDTO) request.getAttribute(PageHandlerMapping.PAGE_ATTRIBUTE_NAME);
assert page != null;
model.addObject(MODEL_ATTRIBUTE_NAME, page);
// For convenience
model.addObject("pageFields", page.getPageFields());
model.addObject("BLC_PAGE_TYPE", "page");
String plainTextStr = (String) page.getPageFields().get("plainText");
if (!StringUtils.isEmpty(plainTextStr)) {
if (Boolean.valueOf(plainTextStr)) {
response.setCharacterEncoding("UTF-8");
response.setContentType("text/plain");
}
}
String templatePath = page.getTemplatePath();
// Allow extension managers to override the path.
ExtensionResultHolder<String> erh = new ExtensionResultHolder<String>();
Boolean internalValidateFindPreviouslySet = false;
ExtensionResultStatusType extResult;
try {
if (!BroadleafRequestContext.getBroadleafRequestContext().getInternalValidateFind()) {
BroadleafRequestContext.getBroadleafRequestContext().setInternalValidateFind(true);
internalValidateFindPreviouslySet = true;
}
extResult = templateOverrideManager.getProxy().getOverrideTemplate(erh, page);
} finally {
if (internalValidateFindPreviouslySet) {
BroadleafRequestContext.getBroadleafRequestContext().setInternalValidateFind(false);
}
}
if (extResult != ExtensionResultStatusType.NOT_HANDLED) {
templatePath = erh.getResult();
}
model.setViewName(templatePath);
addDeepLink(model, deepLinkService, page);
return model;
}
use of org.broadleafcommerce.common.extension.ExtensionResultStatusType in project BroadleafCommerce by BroadleafCommerce.
the class BroadleafFileServiceImpl method getLocalResource.
protected File getLocalResource(String resourceName, boolean skipSite) {
if (skipSite) {
String baseDirectory = getBaseDirectory(skipSite);
// convert the separators to the system this is currently run on
String systemResourcePath = FilenameUtils.separatorsToSystem(resourceName);
String filePath = FilenameUtils.normalize(baseDirectory + File.separator + systemResourcePath);
return new File(filePath);
} else {
String baseDirectory = getBaseDirectory(true);
ExtensionResultHolder<String> holder = new ExtensionResultHolder<String>();
if (extensionManager != null) {
ExtensionResultStatusType result = extensionManager.getProxy().processPathForSite(baseDirectory, resourceName, holder);
if (!ExtensionResultStatusType.NOT_HANDLED.equals(result)) {
return new File(holder.getResult());
}
}
return getLocalResource(resourceName, true);
}
}
use of org.broadleafcommerce.common.extension.ExtensionResultStatusType in project BroadleafCommerce by BroadleafCommerce.
the class FileSystemFileServiceProvider method getResource.
@Override
public File getResource(String url, FileApplicationType applicationType) {
String fileName = buildResourceName(url);
String baseDirectory = getBaseDirectory(true);
ExtensionResultHolder<String> holder = new ExtensionResultHolder<String>();
if (extensionManager != null) {
ExtensionResultStatusType result = extensionManager.getProxy().processPathForSite(baseDirectory, fileName, holder);
if (!ExtensionResultStatusType.NOT_HANDLED.equals(result)) {
return new File(holder.getResult());
}
}
String filePath = FilenameUtils.normalize(getBaseDirectory(false) + File.separator + fileName);
return new File(filePath);
}
use of org.broadleafcommerce.common.extension.ExtensionResultStatusType in project BroadleafCommerce by BroadleafCommerce.
the class BroadleafProductController method handleRequest.
@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
ModelAndView model = new ModelAndView();
Product product = (Product) request.getAttribute(ProductHandlerMapping.CURRENT_PRODUCT_ATTRIBUTE_NAME);
assert (product != null);
model.addObject(MODEL_ATTRIBUTE_NAME, product);
model.addObject(PAGE_TYPE_ATTRIBUTE_NAME, "product");
// Build the add to cart request and add it to the page
ConfigurableOrderItemRequest itemRequest = orderItemService.createConfigurableOrderItemRequestFromProduct(product);
orderItemService.modifyOrderItemRequest(itemRequest);
model.addObject(CONFIGURATION_ATTRIBUTE_NAME, itemRequest);
model.addObject(ALL_PRODUCTS_ATTRIBUTE_NAME, orderItemService.findAllProductsInRequest(itemRequest));
addDeepLink(model, deepLinkService, product);
String templatePath;
// Use the products custom template if available
if (StringUtils.isNotBlank(product.getDisplayTemplate())) {
templatePath = product.getDisplayTemplate();
} else {
// Otherwise, use the controller default.
templatePath = getDefaultProductView();
}
// Allow extension managers to override.
ExtensionResultHolder<String> erh = new ExtensionResultHolder<String>();
ExtensionResultStatusType extResult = templateOverrideManager.getProxy().getOverrideTemplate(erh, product);
if (extResult != ExtensionResultStatusType.NOT_HANDLED) {
templatePath = erh.getResult();
}
model.setViewName(templatePath);
// Check if this is request to edit an existing order item
String isEditRequest = request.getParameter("edit");
String oidParam = request.getParameter("oid");
if (StringUtils.isNotEmpty(isEditRequest) && StringUtils.isNotEmpty(oidParam)) {
Long oid = Long.parseLong(oidParam);
OrderItem orderItem = orderItemService.readOrderItemById(oid);
if (orderItemBelongsToCurrentCustomer(orderItem)) {
// Update the itemRequest to contain user's previous input
orderItemService.mergeOrderItemRequest(itemRequest, orderItem);
// Add the order item to the model
model.addObject("isUpdateRequest", true);
model.addObject("orderItem", orderItem);
}
}
return model;
}
use of org.broadleafcommerce.common.extension.ExtensionResultStatusType in project BroadleafCommerce by BroadleafCommerce.
the class OrderServiceImpl method findCartForCustomerWithEnhancements.
@Override
public Order findCartForCustomerWithEnhancements(Customer customer) {
ExtensionResultHolder<Order> erh = new ExtensionResultHolder<Order>();
ExtensionResultStatusType resultStatusType = extensionManager.findCartForCustomerWithEnhancements(customer, erh);
if (ExtensionResultStatusType.NOT_HANDLED != resultStatusType) {
return erh.getResult();
}
return findCartForCustomer(customer);
}
Aggregations