use of org.broadleafcommerce.common.web.BroadleafRequestContext in project BroadleafCommerce by BroadleafCommerce.
the class SystemPropertiesDaoImpl method getSite.
protected String getSite() {
String site = "";
BroadleafRequestContext brc = BroadleafRequestContext.getBroadleafRequestContext();
if (brc != null) {
if (brc.getSite() != null) {
site = String.valueOf(brc.getSite().getId());
}
}
return site;
}
use of org.broadleafcommerce.common.web.BroadleafRequestContext in project BroadleafCommerce by BroadleafCommerce.
the class SystemPropertiesServiceImpl method buildKey.
/**
* Properties can vary by site. If a site is found on the request, use the site id as part of the
* cache-key.
*
* @param propertyName
* @return
*/
protected String buildKey(String propertyName) {
Long siteId = null;
BroadleafRequestContext brc = BroadleafRequestContext.getBroadleafRequestContext();
if (brc != null) {
if (brc.getSite() != null) {
siteId = brc.getSite().getId();
}
}
return buildKey(propertyName, siteId);
}
use of org.broadleafcommerce.common.web.BroadleafRequestContext in project BroadleafCommerce by BroadleafCommerce.
the class BroadleafFileServiceImpl method getBaseDirectory.
/**
* Returns the baseDirectory for writing and reading files as the property assetFileSystemPath if it
* exists or java.tmp.io if that property has not been set.
*/
protected String getBaseDirectory(boolean skipSite) {
String path = "";
if (StringUtils.isBlank(tempFileSystemBaseDirectory)) {
path = DEFAULT_STORAGE_DIRECTORY;
} else {
path = tempFileSystemBaseDirectory;
}
if (!skipSite) {
// Create site specific directory if Multi-site (all site files will be located in the same directory)
BroadleafRequestContext brc = BroadleafRequestContext.getBroadleafRequestContext();
if (brc != null && brc.getSite() != null) {
String siteDirectory = "site-" + brc.getSite().getId();
String siteHash = DigestUtils.md5Hex(siteDirectory);
path = FilenameUtils.concat(path, siteHash.substring(0, 2));
path = FilenameUtils.concat(path, siteDirectory);
}
}
return path;
}
use of org.broadleafcommerce.common.web.BroadleafRequestContext in project BroadleafCommerce by BroadleafCommerce.
the class BLCVariableExpression method getPrice.
/**
* Returns the price at the correct scale and rounding for the default currency
* @see Money#defaultCurrency()
* @param amount
* @return
*/
public String getPrice(String amount) {
Money price = Money.ZERO;
String sanitizedAmount = StringUtil.removeNonNumerics(amount);
if (StringUtils.isNotEmpty(sanitizedAmount)) {
price = new Money(sanitizedAmount);
BroadleafRequestContext brc = BroadleafRequestContext.getBroadleafRequestContext();
if (brc.getJavaLocale() != null) {
NumberFormat formatter = BroadleafCurrencyUtils.getNumberFormatFromCache(brc.getJavaLocale(), price.getCurrency());
return formatter.format(price.getAmount());
}
}
return "$ " + price.getAmount().toString();
}
use of org.broadleafcommerce.common.web.BroadleafRequestContext in project BroadleafCommerce by BroadleafCommerce.
the class BLCVariableExpression method getCurrentUrl.
protected String getCurrentUrl() {
BroadleafRequestContext brc = BroadleafRequestContext.getBroadleafRequestContext();
String currentUrl = "";
if (brc != null && brc.getRequest() != null) {
currentUrl = brc.getRequest().getRequestURI();
if (!StringUtils.isEmpty(brc.getRequest().getQueryString())) {
currentUrl = currentUrl + "?" + brc.getRequest().getQueryString();
}
}
return currentUrl;
}
Aggregations