Search in sources :

Example 6 with SystemProperty

use of org.broadleafcommerce.common.config.domain.SystemProperty 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)

Aggregations

SystemProperty (org.broadleafcommerce.common.config.domain.SystemProperty)6 SystemPropertyImpl (org.broadleafcommerce.common.config.domain.SystemPropertyImpl)3 ServiceException (org.broadleafcommerce.common.exception.ServiceException)2 Entity (org.broadleafcommerce.openadmin.dto.Entity)2 FieldMetadata (org.broadleafcommerce.openadmin.dto.FieldMetadata)2 PersistencePerspective (org.broadleafcommerce.openadmin.dto.PersistencePerspective)2 Transactional (org.springframework.transaction.annotation.Transactional)2 Test (org.testng.annotations.Test)2 ArrayList (java.util.ArrayList)1 NoResultException (javax.persistence.NoResultException)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Order (javax.persistence.criteria.Order)1 Predicate (javax.persistence.criteria.Predicate)1 ExtensionResultHolder (org.broadleafcommerce.common.extension.ExtensionResultHolder)1