use of org.broadleafcommerce.core.geolocation.GeolocationDTO in project BroadleafCommerce by BroadleafCommerce.
the class GeolocationRequestProcessor method process.
@Override
public void process(WebRequest request) {
if (isGeolocationEnabled()) {
if (request instanceof ServletWebRequest) {
ServletWebRequest servletWebRequest = (ServletWebRequest) request;
GeolocationDTO location = (GeolocationDTO) BLCRequestUtils.getSessionAttributeIfOk(request, GEOLOCATON_ATTRIBUTE_NAME);
if (location == null) {
String ipAddress = getIPAddress(servletWebRequest);
location = geolocationService.getLocationData(ipAddress);
BLCRequestUtils.setSessionAttributeIfOk(request, GEOLOCATON_ATTRIBUTE_NAME, location);
}
BroadleafRequestContext.getBroadleafRequestContext().getAdditionalProperties().put(GEOLOCATON_ATTRIBUTE_NAME, location);
Map<String, Object> ruleMap = getRuleMapFromRequest(request);
ruleMap.put(GEOLOCATON_ATTRIBUTE_NAME, location);
request.setAttribute(BLC_RULE_MAP_PARAM, ruleMap, WebRequest.SCOPE_REQUEST);
}
}
}
Aggregations