Search in sources :

Example 76 with BroadleafRequestContext

use of org.broadleafcommerce.common.web.BroadleafRequestContext in project BroadleafCommerce by BroadleafCommerce.

the class SolrConfiguration method getSiteServer.

public SolrClient getSiteServer() {
    BroadleafRequestContext ctx = BroadleafRequestContext.getBroadleafRequestContext();
    Site site = ctx.getNonPersistentSite();
    CloudSolrClient client = (CloudSolrClient) primaryServer;
    client.connect();
    String aliasName = getSiteAliasName(site);
    if (aliasName != null) {
        String collectionName = getSiteCollectionName(site);
        createCollectionIfNotExist(client, collectionName);
        createAliasIfNotExist(client, collectionName, collectionName);
    }
    return client;
}
Also used : Site(org.broadleafcommerce.common.site.domain.Site) BroadleafRequestContext(org.broadleafcommerce.common.web.BroadleafRequestContext) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient)

Example 77 with BroadleafRequestContext

use of org.broadleafcommerce.common.web.BroadleafRequestContext in project BroadleafCommerce by BroadleafCommerce.

the class SolrSearchServiceImpl method createSearchContextDTO.

protected SearchContextDTO createSearchContextDTO() {
    SearchContextDTO searchContextDTO = new SearchContextDTO();
    BroadleafRequestContext ctx = BroadleafRequestContext.getBroadleafRequestContext();
    if (ctx != null) {
        Map<String, Object> ruleMap = (Map<String, Object>) ctx.getRequestAttribute("blRuleMap");
        if (MapUtils.isNotEmpty(ruleMap)) {
            searchContextDTO.setAttributes(ruleMap);
        }
    }
    return searchContextDTO;
}
Also used : BroadleafRequestContext(org.broadleafcommerce.common.web.BroadleafRequestContext) Map(java.util.Map)

Example 78 with BroadleafRequestContext

use of org.broadleafcommerce.common.web.BroadleafRequestContext in project BroadleafCommerce by BroadleafCommerce.

the class SolrIndexCachedOperation method getCache.

/**
 * Retrieve the cache bound to the current thread.
 *
 * @return The cache for the current thread, or null if not set
 */
public static CatalogStructure getCache() {
    BroadleafRequestContext ctx = BroadleafRequestContext.getBroadleafRequestContext();
    Catalog currentCatalog = ctx == null ? null : ctx.getCurrentCatalog();
    if (currentCatalog != null) {
        return MapUtils.getObject(CACHE.get(), currentCatalog.getId());
    } else {
        return MapUtils.getObject(CACHE.get(), DEFAULT_CATALOG_CACHE_KEY);
    }
}
Also used : BroadleafRequestContext(org.broadleafcommerce.common.web.BroadleafRequestContext) Catalog(org.broadleafcommerce.common.site.domain.Catalog)

Aggregations

BroadleafRequestContext (org.broadleafcommerce.common.web.BroadleafRequestContext)78 Site (org.broadleafcommerce.common.site.domain.Site)16 HashMap (java.util.HashMap)12 HttpServletRequest (javax.servlet.http.HttpServletRequest)11 ArrayList (java.util.ArrayList)9 Map (java.util.Map)9 Locale (org.broadleafcommerce.common.locale.domain.Locale)8 SandBox (org.broadleafcommerce.common.sandbox.domain.SandBox)5 StructuredContentDTO (org.broadleafcommerce.common.structure.dto.StructuredContentDTO)5 MessageSource (org.springframework.context.MessageSource)5 List (java.util.List)4 StructuredContent (org.broadleafcommerce.cms.structure.domain.StructuredContent)4 Field (java.lang.reflect.Field)3 HashSet (java.util.HashSet)3 Locale (java.util.Locale)3 Catalog (org.broadleafcommerce.common.site.domain.Catalog)3 BroadleafAttributeModifier (org.broadleafcommerce.presentation.model.BroadleafAttributeModifier)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 File (java.io.File)2 PrintWriter (java.io.PrintWriter)2