Subversion Repositories SmartDukaan

Rev

Rev 16290 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16290 Rev 16291
Line 3... Line 3...
3
 */
3
 */
4
package in.shop2020.serving.services;
4
package in.shop2020.serving.services;
5
 
5
 
6
 
6
 
7
import in.shop2020.config.ConfigException;
7
import in.shop2020.config.ConfigException;
8
import in.shop2020.model.v1.catalog.PrivateDeal;
-
 
9
import in.shop2020.serving.controllers.SearchController;
8
import in.shop2020.serving.controllers.SearchController;
10
import in.shop2020.serving.utils.Utils;
9
import in.shop2020.serving.utils.Utils;
11
import in.shop2020.thrift.clients.config.ConfigClient;
10
import in.shop2020.thrift.clients.config.ConfigClient;
12
 
11
 
13
import java.io.UnsupportedEncodingException;
12
import java.io.UnsupportedEncodingException;
-
 
13
import java.net.URI;
-
 
14
import java.net.URL;
-
 
15
import java.net.URLDecoder;
14
import java.net.URLEncoder;
16
import java.net.URLEncoder;
15
import java.util.ArrayList;
17
import java.util.ArrayList;
16
import java.util.Arrays;
18
import java.util.Arrays;
17
import java.util.Collections;
19
import java.util.Collections;
18
import java.util.HashMap;
20
import java.util.HashMap;
Line 30... Line 32...
30
import javax.xml.xpath.XPath;
32
import javax.xml.xpath.XPath;
31
import javax.xml.xpath.XPathConstants;
33
import javax.xml.xpath.XPathConstants;
32
import javax.xml.xpath.XPathExpressionException;
34
import javax.xml.xpath.XPathExpressionException;
33
import javax.xml.xpath.XPathFactory;
35
import javax.xml.xpath.XPathFactory;
34
 
36
 
35
import org.apache.commons.codec.Encoder;
37
import org.apache.commons.codec.net.URLCodec;
36
import org.apache.commons.collections.ListUtils;
-
 
37
import org.apache.log4j.Logger;
38
import org.apache.log4j.Logger;
38
import org.w3c.dom.Node;
39
import org.w3c.dom.Node;
39
import org.w3c.dom.NodeList;
40
import org.w3c.dom.NodeList;
40
import org.xml.sax.InputSource;
41
import org.xml.sax.InputSource;
41
 
42
 
Line 217... Line 218...
217
		}
218
		}
218
		String minString = "0";
219
		String minString = "0";
219
		String maxString = "*";  
220
		String maxString = "*";  
220
		if(minPrice != null || maxPrice != null){
221
		if(minPrice != null || maxPrice != null){
221
			try {
222
			try {
222
				dynamicPriceMap = getPriceStatsMap(new InputSource(URLEncoder.encode(uri, "UTF-8"))); 
223
				dynamicPriceMap = getPriceStatsMap(new InputSource(uri)); 
223
			} catch (Exception e){
224
			} catch (Exception e){
224
				e.printStackTrace();
225
				e.printStackTrace();
225
			}
226
			}
226
			if(minPrice != null){
227
			if(minPrice != null){
227
				minString = minPrice.toString();
228
				minString = minPrice.toString();
Line 240... Line 241...
240
				}
241
				}
241
		}
242
		}
242
		log.info("uri=" + uri);
243
		log.info("uri=" + uri);
243
		
244
		
244
		try{
245
		try{
245
			this.inputSource = new InputSource(URLEncoder.encode(uri,"UTF-8"));
246
			this.inputSource = new InputSource(toUri(uri));
246
		}catch(Exception e){
247
		}catch(Exception e){
247
			log.info("Could not make it");
248
			log.info("Could not make it");
248
		}
249
		}
249
 
250
 
250
		this.facetMap = getFacetMap();
251
		this.facetMap = getFacetMap();
Line 748... Line 749...
748
	}
749
	}
749
 
750
 
750
	public boolean isPrivateDealUser() {
751
	public boolean isPrivateDealUser() {
751
		return isPrivateDealUser;
752
		return isPrivateDealUser;
752
	}
753
	}
-
 
754
	
-
 
755
	public String toUri(String string){
-
 
756
	    try {
-
 
757
	        String decodedURL = URLDecoder.decode(string, "UTF-8");
-
 
758
	        URL url = new URL(decodedURL);
-
 
759
	        URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); 
-
 
760
	        return uri.toASCIIString(); 
-
 
761
	    } catch (Exception ex) {
-
 
762
	        ex.printStackTrace();
-
 
763
	        return null;
-
 
764
	    }
-
 
765
	}
753
    
766
    
754
}
767
}