Subversion Repositories SmartDukaan

Rev

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

Rev 13878 Rev 13888
Line 16... Line 16...
16
import org.apache.http.impl.client.DefaultHttpClient;
16
import org.apache.http.impl.client.DefaultHttpClient;
17
import org.apache.http.message.BasicNameValuePair;
17
import org.apache.http.message.BasicNameValuePair;
18
 
18
 
19
public class UpdateSDIUsingPanel {
19
public class UpdateSDIUsingPanel {
20
	private static DefaultHttpClient client = new DefaultHttpClient();
20
	private static DefaultHttpClient client = new DefaultHttpClient();
21
	public static void main(String... args) throws ClientProtocolException, IOException{
21
	public static void main(String... args) throws ClientProtocolException, IOException, InterruptedException{
22
		System.out.println("Inside main");
22
		System.out.println("Inside main");
23
		UpdateSDIUsingPanel UDSI = new UpdateSDIUsingPanel();
23
		UpdateSDIUsingPanel UDSI = new UpdateSDIUsingPanel();
-
 
24
		UDSI.handleLogin();
24
		System.out.println("Created UD Inventory object");
25
		System.out.println("Created UD Inventory object");
25
		UDSI.updateInventory(98L,"SDL061548809");
26
		UDSI.updateInventory(32L,"SDL689893640");
26
		System.out.println("After calling update inventory");
27
		System.out.println("After calling update inventory");
27
 
28
 
28
	}
29
	}
29
	int updateInventory(long stock,String supc) throws ClientProtocolException, IOException{
30
	int updateInventory(long stock,String supc) throws ClientProtocolException, IOException, InterruptedException{
30
		HttpPost post = new HttpPost("http://seller.snapdeal.com/inventory/update");
31
		HttpPost post = new HttpPost("http://seller.snapdeal.com/inventory/update");
31
		List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
32
		List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
32
		System.out.println("Calling update inventory: Supc: "+supc+ " to be update stock: "+ stock);
33
		System.out.println("Calling update inventory: Supc: "+supc+ " to be update stock: "+ stock);
33
		nameValuePairs.add(new BasicNameValuePair("changedField",
34
		nameValuePairs.add(new BasicNameValuePair("changedField",
34
				"inventory"));
35
				"inventory"));
Line 41... Line 42...
41
		BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
42
		BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
42
		String line = "";
43
		String line = "";
43
		while ((line = rd.readLine()) != null) {
44
		while ((line = rd.readLine()) != null) {
44
			System.out.println(line);
45
			System.out.println(line);
45
		}
46
		}
-
 
47
		Thread.sleep(1000);
46
		return 1;
48
		return 1;
47
	}
49
	}
48
 
50
 
49
	public void handleLogin() throws ClientProtocolException, IOException{
51
	public void handleLogin() throws ClientProtocolException, IOException{
50
		HttpGet get = new HttpGet("http://selleraccounts.snapdeal.com/login?service=http%3A%2F%2Fseller.snapdeal.com%2Fj_spring_cas_security_check");
52
		HttpGet get = new HttpGet("http://selleraccounts.snapdeal.com/login?service=http%3A%2F%2Fseller.snapdeal.com%2Fj_spring_cas_security_check");