| Line 11... |
Line 11... |
| 11 |
import in.shop2020.model.v1.user.Line;
|
11 |
import in.shop2020.model.v1.user.Line;
|
| 12 |
import in.shop2020.thrift.clients.CatalogClient;
|
12 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 13 |
import in.shop2020.thrift.clients.TransactionClient;
|
13 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 14 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
14 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
| 15 |
|
15 |
|
| - |
|
16 |
import java.io.BufferedReader;
|
| - |
|
17 |
import java.io.IOException;
|
| - |
|
18 |
import java.io.InputStream;
|
| - |
|
19 |
import java.io.InputStreamReader;
|
| 16 |
import java.util.ArrayList;
|
20 |
import java.util.ArrayList;
|
| 17 |
import java.util.Arrays;
|
21 |
import java.util.Arrays;
|
| 18 |
import java.util.Collections;
|
22 |
import java.util.Collections;
|
| 19 |
import java.util.Date;
|
23 |
import java.util.Date;
|
| 20 |
import java.util.HashMap;
|
24 |
import java.util.HashMap;
|
| Line 23... |
Line 27... |
| 23 |
|
27 |
|
| 24 |
import javax.mail.internet.AddressException;
|
28 |
import javax.mail.internet.AddressException;
|
| 25 |
import javax.mail.internet.InternetAddress;
|
29 |
import javax.mail.internet.InternetAddress;
|
| 26 |
|
30 |
|
| 27 |
import org.apache.commons.lang.StringUtils;
|
31 |
import org.apache.commons.lang.StringUtils;
|
| - |
|
32 |
import org.apache.http.HttpEntity;
|
| - |
|
33 |
import org.apache.http.HttpResponse;
|
| - |
|
34 |
import org.apache.http.client.HttpClient;
|
| - |
|
35 |
import org.apache.http.client.methods.HttpGet;
|
| - |
|
36 |
import org.apache.http.impl.client.DefaultHttpClient;
|
| 28 |
import org.apache.log4j.Logger;
|
37 |
import org.apache.log4j.Logger;
|
| 29 |
|
38 |
|
| 30 |
public class Utils {
|
39 |
public class Utils {
|
| 31 |
private static Logger logger = Logger.getLogger(Utils.class);
|
40 |
private static Logger logger = Logger.getLogger(Utils.class);
|
| 32 |
|
41 |
|
| Line 37... |
Line 46... |
| 37 |
public static final long MOBILE_PHONES_CATEGORY = 10001;
|
46 |
public static final long MOBILE_PHONES_CATEGORY = 10001;
|
| 38 |
public static final long MOBILE_ACCESSORIES_CATEGORY = 10011;
|
47 |
public static final long MOBILE_ACCESSORIES_CATEGORY = 10011;
|
| 39 |
public static final long TABLETS_CATEGORY = 10010;
|
48 |
public static final long TABLETS_CATEGORY = 10010;
|
| 40 |
public static final long LAPTOPS_CATEGORY = 10050;
|
49 |
public static final long LAPTOPS_CATEGORY = 10050;
|
| 41 |
public static final long CAMERAS_CATEGORY = 11001;
|
50 |
public static final long CAMERAS_CATEGORY = 11001;
|
| - |
|
51 |
private static final String DTR_ENTITY_URL = "http://dtr:8057/something%d";
|
| 42 |
|
52 |
|
| 43 |
@SuppressWarnings("serial")
|
53 |
@SuppressWarnings("serial")
|
| 44 |
public static final Map<String, String> NET_BANKING_CODES_MAP = Collections.unmodifiableMap(
|
54 |
public static final Map<String, String> NET_BANKING_CODES_MAP = Collections.unmodifiableMap(
|
| 45 |
new HashMap<String, String>(){
|
55 |
new HashMap<String, String>(){
|
| 46 |
{
|
56 |
{
|
| Line 90... |
Line 100... |
| 90 |
static Map<Long, String> dthProvidersMap;
|
100 |
static Map<Long, String> dthProvidersMap;
|
| 91 |
static Map<Long, List<RechargePlan>> operatorPlanMap = new HashMap<Long, List<RechargePlan>>();
|
101 |
static Map<Long, List<RechargePlan>> operatorPlanMap = new HashMap<Long, List<RechargePlan>>();
|
| 92 |
private static Map<String, Map<String, String>> uriOperatorMap = new HashMap<String, Map<String,String>>();
|
102 |
private static Map<String, Map<String, String>> uriOperatorMap = new HashMap<String, Map<String,String>>();
|
| 93 |
static Map<Long, ExclusiveAffiliateItemInfo> exclusiveAffiliateItems = null;
|
103 |
static Map<Long, ExclusiveAffiliateItemInfo> exclusiveAffiliateItems = null;
|
| 94 |
static long fifteenMinsCounter = 0l;
|
104 |
static long fifteenMinsCounter = 0l;
|
| - |
|
105 |
static long thirtyMinsCounter = 0l;
|
| 95 |
|
106 |
|
| 96 |
public static final List<RechargeOrderStatus> refundableRechargeStatusList = new ArrayList<RechargeOrderStatus>(Arrays.asList(new RechargeOrderStatus[]
|
107 |
public static final List<RechargeOrderStatus> refundableRechargeStatusList = new ArrayList<RechargeOrderStatus>(Arrays.asList(new RechargeOrderStatus[]
|
| 97 |
{RechargeOrderStatus.RECHARGE_FAILED,
|
108 |
{RechargeOrderStatus.RECHARGE_FAILED,
|
| 98 |
RechargeOrderStatus.RECHARGE_FAILED_REFUNDED}));
|
109 |
RechargeOrderStatus.RECHARGE_FAILED_REFUNDED}));
|
| 99 |
|
110 |
|
| Line 315... |
Line 326... |
| 315 |
|
326 |
|
| 316 |
public static Map<Long, ExclusiveAffiliateItemInfo> getExclusiveAffiliateItems(){
|
327 |
public static Map<Long, ExclusiveAffiliateItemInfo> getExclusiveAffiliateItems(){
|
| 317 |
try{
|
328 |
try{
|
| 318 |
Long currentTime = new Date().getTime();
|
329 |
Long currentTime = new Date().getTime();
|
| 319 |
CatalogClient client = new CatalogClient();
|
330 |
CatalogClient client = new CatalogClient();
|
| 320 |
if(exclusiveAffiliateItems == null || fifteenMinsCounter < currentTime) {
|
331 |
if(exclusiveAffiliateItems == null || thirtyMinsCounter < currentTime) {
|
| 321 |
exclusiveAffiliateItems = client.getClient().getExAffiliateItemInfo();
|
332 |
exclusiveAffiliateItems = client.getClient().getExAffiliateItemInfo();
|
| 322 |
fifteenMinsCounter = new Date().getTime() + 15*60000;
|
333 |
thirtyMinsCounter = new Date().getTime() + 15*60000;
|
| 323 |
}
|
334 |
}
|
| 324 |
}catch(Exception ce){
|
335 |
}catch(Exception ce){
|
| 325 |
logger.error("Unable to fetch exclusive items from catalog", ce);
|
336 |
logger.error("Unable to fetch exclusive items from catalog", ce);
|
| 326 |
}
|
337 |
}
|
| 327 |
return exclusiveAffiliateItems;
|
338 |
return exclusiveAffiliateItems;
|
| 328 |
}
|
339 |
}
|
| - |
|
340 |
|
| - |
|
341 |
public static String getDtrAffiliateString(Long entityId){
|
| - |
|
342 |
HttpClient httpclient = new DefaultHttpClient();
|
| - |
|
343 |
|
| - |
|
344 |
String url = String.format(DTR_ENTITY_URL, entityId);
|
| - |
|
345 |
HttpGet httpget = new HttpGet(url);
|
| - |
|
346 |
String str = "";
|
| - |
|
347 |
// If the response does not enclose an entity, there is no need
|
| - |
|
348 |
// to worry about connection release
|
| - |
|
349 |
try{
|
| - |
|
350 |
HttpResponse response = httpclient.execute(httpget);
|
| - |
|
351 |
// Get hold of the response entity
|
| - |
|
352 |
HttpEntity entity = response.getEntity();
|
| - |
|
353 |
if (entity != null) {
|
| - |
|
354 |
InputStream instream = entity.getContent();
|
| - |
|
355 |
try {
|
| - |
|
356 |
BufferedReader reader = new BufferedReader(new InputStreamReader(instream));
|
| - |
|
357 |
str = reader.readLine();
|
| - |
|
358 |
} catch (IOException ex) {
|
| - |
|
359 |
throw ex;
|
| - |
|
360 |
} catch (RuntimeException ex) {
|
| - |
|
361 |
httpget.abort();
|
| - |
|
362 |
throw ex;
|
| - |
|
363 |
|
| - |
|
364 |
} finally {
|
| - |
|
365 |
// Closing the input stream will trigger connection release
|
| - |
|
366 |
instream.close();
|
| - |
|
367 |
}
|
| - |
|
368 |
}
|
| - |
|
369 |
} catch (Exception e){
|
| - |
|
370 |
e.printStackTrace();
|
| - |
|
371 |
}
|
| - |
|
372 |
httpclient.getConnectionManager().shutdown();
|
| - |
|
373 |
return str;
|
| - |
|
374 |
}
|
| 329 |
}
|
375 |
}
|
| 330 |
|
376 |
|