Subversion Repositories SmartDukaan

Rev

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

Rev 10252 Rev 10255
Line 21... Line 21...
21
import org.apache.http.NameValuePair;
21
import org.apache.http.NameValuePair;
22
import org.apache.http.client.ClientProtocolException;
22
import org.apache.http.client.ClientProtocolException;
23
import org.apache.http.client.entity.UrlEncodedFormEntity;
23
import org.apache.http.client.entity.UrlEncodedFormEntity;
24
import org.apache.http.client.methods.HttpGet;
24
import org.apache.http.client.methods.HttpGet;
25
import org.apache.http.client.methods.HttpPost;
25
import org.apache.http.client.methods.HttpPost;
-
 
26
import org.apache.http.conn.ClientConnectionManager;
26
import org.apache.http.impl.client.DefaultHttpClient;
27
import org.apache.http.impl.client.DefaultHttpClient;
-
 
28
import org.apache.http.impl.conn.PoolingClientConnectionManager;
27
import org.apache.http.message.BasicNameValuePair;
29
import org.apache.http.message.BasicNameValuePair;
28
import org.apache.thrift.TException;
30
import org.apache.thrift.TException;
29
import org.apache.thrift.transport.TTransportException;
31
import org.apache.thrift.transport.TTransportException;
30
import org.slf4j.Logger;
32
import org.slf4j.Logger;
31
import org.slf4j.LoggerFactory;
33
import org.slf4j.LoggerFactory;
32
 
34
 
33
public class UpdateSDPricingUsingPanel extends Thread{
35
public class UpdateSDPricingUsingPanel extends Thread{
-
 
36
	static ClientConnectionManager connManager = new PoolingClientConnectionManager();
34
	private static DefaultHttpClient httpClient = new DefaultHttpClient();
37
	private static DefaultHttpClient httpClient = new DefaultHttpClient(connManager);
35
	private Float price;
38
	private Float price;
36
	private String supc;
39
	private String supc;
37
	private Item item;
40
	private Item item;
38
	private Long timestamp;
41
	private Long timestamp;
39
	public String[] sendTo = new String[]{"vikram.raghav@shop2020.in"};
42
	public String[] sendTo = new String[]{"vikram.raghav@shop2020.in"};
Line 52... Line 55...
52
	 }
55
	 }
53
	 public UpdateSDPricingUsingPanel() {
56
	 public UpdateSDPricingUsingPanel() {
54
	 }
57
	 }
55
	 public static void main(String... args) throws ClientProtocolException, IOException, TTransportException, CatalogServiceException, TException{
58
	 public static void main(String... args) throws ClientProtocolException, IOException, TTransportException, CatalogServiceException, TException{
56
		 Item item = new CatalogClient().getClient().getItem(2231);
59
		 Item item = new CatalogClient().getClient().getItem(2231);
57
		 UpdateSDPricingUsingPanel updatePriceOnSnapdeal = new UpdateSDPricingUsingPanel(22500f,"1108903",item,System.currentTimeMillis());
60
		 UpdateSDPricingUsingPanel updatePriceOnSnapdeal = new UpdateSDPricingUsingPanel(22200f,"1108903",item,System.currentTimeMillis());
58
		 logger.info("Calling Thread to update price at snapdeal");
61
		 logger.info("Calling Thread to update price at snapdeal");
59
		 updatePriceOnSnapdeal.start();	
62
		 updatePriceOnSnapdeal.start();	
60
 
63
 
61
	 }
64
	 }
62
	 int updatePricing(Float price,String supc,Item item,Long timestamp) throws ClientProtocolException, IOException{
65
	 int updatePricing(Float price,String supc,Item item,Long timestamp) throws ClientProtocolException, IOException{
Line 84... Line 87...
84
		 HttpResponse response = null;
87
		 HttpResponse response = null;
85
		 try {
88
		 try {
86
			 response = httpClient.execute(get);
89
			 response = httpClient.execute(get);
87
		 } catch (ClientProtocolException e) {
90
		 } catch (ClientProtocolException e) {
88
			 e.printStackTrace();
91
			 e.printStackTrace();
89
			 logger.info("Exception" + e);
92
			 logger.info("Exception " + e);
90
		 } catch (IOException e) {
93
		 } catch (IOException e) {
91
			 e.printStackTrace();
94
			 e.printStackTrace();
92
			 logger.info("Exception" + e);
95
			 logger.info("Exception " + e);
93
		 }
96
		 }
94
		 BufferedReader rd = null;
97
		 BufferedReader rd = null;
95
		 try {
98
		 try {
96
			 rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
99
			 rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
97
		 } catch (IllegalStateException e1) {
100
		 } catch (IllegalStateException e1) {