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;
}
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;
}
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;
}
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);
}
}
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);
}
Aggregations