Search in sources :

Example 36 with ExtensionResultHolder

use of org.broadleafcommerce.common.extension.ExtensionResultHolder in project BroadleafCommerce by BroadleafCommerce.

the class ValidateCheckoutActivity method execute.

@Override
public ProcessContext<CheckoutSeed> execute(ProcessContext<CheckoutSeed> context) throws Exception {
    ExtensionResultHolder<Exception> resultHolder = new ExtensionResultHolder<>();
    resultHolder.setResult(null);
    ExtensionResultStatusType result = extensionManager.getProxy().validateCheckout(context.getSeedData(), resultHolder);
    if (!ExtensionResultStatusType.NOT_HANDLED.equals(result)) {
        if (resultHolder.getResult() != null) {
            throw resultHolder.getResult();
        }
    }
    return context;
}
Also used : ExtensionResultStatusType(org.broadleafcommerce.common.extension.ExtensionResultStatusType) ExtensionResultHolder(org.broadleafcommerce.common.extension.ExtensionResultHolder)

Example 37 with ExtensionResultHolder

use of org.broadleafcommerce.common.extension.ExtensionResultHolder 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;
}
Also used : PageDTO(org.broadleafcommerce.common.page.dto.PageDTO) ModelAndView(org.springframework.web.servlet.ModelAndView) ExtensionResultStatusType(org.broadleafcommerce.common.extension.ExtensionResultStatusType) ExtensionResultHolder(org.broadleafcommerce.common.extension.ExtensionResultHolder)

Example 38 with ExtensionResultHolder

use of org.broadleafcommerce.common.extension.ExtensionResultHolder in project BroadleafCommerce by BroadleafCommerce.

the class SystemPropertiesServiceImpl method resolveSystemProperty.

@Override
public String resolveSystemProperty(String name) {
    if (extensionManager != null) {
        ExtensionResultHolder holder = new ExtensionResultHolder();
        extensionManager.getProxy().resolveProperty(name, holder);
        if (holder.getResult() != null) {
            return holder.getResult().toString();
        }
    }
    String result;
    // We don't want to utilize this cache for sandboxes
    if (BroadleafRequestContext.getBroadleafRequestContext() == null || BroadleafRequestContext.getBroadleafRequestContext().getSandBox() == null) {
        result = getPropertyFromCache(name);
    } else {
        result = null;
    }
    if (result != null) {
        return result.equals(NULL_RESPONSE) ? null : result;
    }
    SystemProperty property = systemPropertiesDao.readSystemPropertyByName(name);
    boolean envOrigination = BooleanUtils.isTrue(originatedFromEnvironment.get());
    if (property == null || StringUtils.isEmpty(property.getValue())) {
        if (envOrigination) {
            result = null;
        } else {
            result = getPropertyFromCache(name);
            if (result == null) {
                result = env.getProperty(name);
            }
        }
    } else {
        if ("_blank_".equals(property.getValue())) {
            result = "";
        } else {
            result = property.getValue();
        }
    }
    if (result == null) {
        result = NULL_RESPONSE;
    }
    addPropertyToCache(name, result);
    return result.equals(NULL_RESPONSE) ? null : result;
}
Also used : SystemProperty(org.broadleafcommerce.common.config.domain.SystemProperty) ExtensionResultHolder(org.broadleafcommerce.common.extension.ExtensionResultHolder)

Example 39 with ExtensionResultHolder

use of org.broadleafcommerce.common.extension.ExtensionResultHolder 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);
    }
}
Also used : ExtensionResultStatusType(org.broadleafcommerce.common.extension.ExtensionResultStatusType) File(java.io.File) ExtensionResultHolder(org.broadleafcommerce.common.extension.ExtensionResultHolder)

Example 40 with ExtensionResultHolder

use of org.broadleafcommerce.common.extension.ExtensionResultHolder 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);
}
Also used : ExtensionResultStatusType(org.broadleafcommerce.common.extension.ExtensionResultStatusType) File(java.io.File) ExtensionResultHolder(org.broadleafcommerce.common.extension.ExtensionResultHolder)

Aggregations

ExtensionResultHolder (org.broadleafcommerce.common.extension.ExtensionResultHolder)56 ExtensionResultStatusType (org.broadleafcommerce.common.extension.ExtensionResultStatusType)35 ArrayList (java.util.ArrayList)11 Product (org.broadleafcommerce.core.catalog.domain.Product)7 Sku (org.broadleafcommerce.core.catalog.domain.Sku)6 PersistenceException (org.broadleafcommerce.openadmin.server.service.persistence.PersistenceException)6 ParentEntityPersistenceException (org.broadleafcommerce.openadmin.server.service.persistence.ParentEntityPersistenceException)5 FieldNotAvailableException (org.broadleafcommerce.openadmin.server.service.persistence.module.FieldNotAvailableException)5 List (java.util.List)4 Set (java.util.Set)4 File (java.io.File)3 Serializable (java.io.Serializable)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 HashMap (java.util.HashMap)3 Query (javax.persistence.Query)3 TypedQuery (javax.persistence.TypedQuery)3 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)3 AdminMainEntity (org.broadleafcommerce.common.admin.domain.AdminMainEntity)3 Site (org.broadleafcommerce.common.site.domain.Site)3 Category (org.broadleafcommerce.core.catalog.domain.Category)3