Commit 437522b4 authored by spawar's avatar spawar

Changes in product integration for check response code


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@99557 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 89de7b23
...@@ -880,7 +880,13 @@ public class CommonWmsUtil { ...@@ -880,7 +880,13 @@ public class CommonWmsUtil {
try try
{ {
System.out.println("url111--->>["+url+"] ["+product.getSku()+"]"); System.out.println("url111--->>["+url+"] ["+product.getSku()+"]");
StringBuilder urlParameters = new StringBuilder(); //Changed by samadhan on 24/12/2015 for stop product integration start
if(url == null || url.length()==0)
{
return 0;
}
//Changed by samadhan on 24/12/2015 for stop product integration end
StringBuilder urlParameters = new StringBuilder();
urlParameters.append(GetUrlParameters(Product.class, product)); urlParameters.append(GetUrlParameters(Product.class, product));
/* String url = Config.apiUrl; /* String url = Config.apiUrl;
//Concat simple product ids in url parameter //Concat simple product ids in url parameter
...@@ -891,8 +897,16 @@ public class CommonWmsUtil { ...@@ -891,8 +897,16 @@ public class CommonWmsUtil {
// url = Config.apiConfigurableUrl; // if parameter available then call configurable api url // url = Config.apiConfigurableUrl; // if parameter available then call configurable api url
} }
System.out.println("urlParameters----->>["+urlParameters.toString()+"]"); System.out.println("urlParameters----->>["+urlParameters.toString()+"]");
//url = Config.apiUrl; //API url call, defined in config file try
{
System.out.println("urlParametersDecode----->>["+URLDecoder.decode(urlParameters.toString(),"UTF-8")+"]");
}
catch (Exception e)
{
e.printStackTrace();
}
//url = Config.apiUrl; //API url call, defined in config file
URL obj = new URL(url); URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection(); HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST"); //Always do the POST method con.setRequestMethod("POST"); //Always do the POST method
...@@ -918,7 +932,12 @@ public class CommonWmsUtil { ...@@ -918,7 +932,12 @@ public class CommonWmsUtil {
int responseCode = con.getResponseCode(); int responseCode = con.getResponseCode();
System.out.println("responseCode-------->>["+responseCode+"]"); System.out.println("responseCode-------->>["+responseCode+"]");
//Changed by samadhan on 29/12/2015 for throw exception when response code not 200 start
if(responseCode != 200)
{
throw new Exception("Response Code="+responseCode);
}
//Changed by samadhan on 29/12/2015 for throw exception when response code not 200 end
switch (responseCode) { //Capture the response code from server switch (responseCode) { //Capture the response code from server
case 500: case 500:
System.out.println("Unexpected server error."); System.out.println("Unexpected server error.");
...@@ -941,8 +960,17 @@ public class CommonWmsUtil { ...@@ -941,8 +960,17 @@ public class CommonWmsUtil {
Map map = splitQuery(response.toString()); Map map = splitQuery(response.toString());
System.out.println("response---->>: "+response.toString()); System.out.println("response---->>: "+response.toString());
System.out.println("Status: "+(String) map.get("status")); //Changed by samadhan on 24/12/2015 for check status start
System.out.println("Message: "+(String) map.get("message")); String status = (String) map.get("status");
String message = (String) map.get("message");
System.out.println("Status: "+status);
System.out.println("Message: "+message);
if("FAIL".equalsIgnoreCase(checkNull(status)))
{
throw new Exception(message);
}
//Changed by samadhan on 24/12/2015 for check status end
String id = map.get("id").toString(); String id = map.get("id").toString();
if(id != null) if(id != null)
{ {
...@@ -962,7 +990,6 @@ public class CommonWmsUtil { ...@@ -962,7 +990,6 @@ public class CommonWmsUtil {
throw new Exception(e); throw new Exception(e);
//Changed by samadhan D15AKAT003 on 18/05/2015 for throw exception. End //Changed by samadhan D15AKAT003 on 18/05/2015 for throw exception. End
} }
} }
} catch (IOException e) } catch (IOException e)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment