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 {
try
{
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));
/* String url = Config.apiUrl;
//Concat simple product ids in url parameter
......@@ -891,8 +897,16 @@ public class CommonWmsUtil {
// url = Config.apiConfigurableUrl; // if parameter available then call configurable api url
}
System.out.println("urlParameters----->>["+urlParameters.toString()+"]");
//url = Config.apiUrl; //API url call, defined in config file
System.out.println("urlParameters----->>["+urlParameters.toString()+"]");
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);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST"); //Always do the POST method
......@@ -918,7 +932,12 @@ public class CommonWmsUtil {
int responseCode = con.getResponseCode();
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
case 500:
System.out.println("Unexpected server error.");
......@@ -941,8 +960,17 @@ public class CommonWmsUtil {
Map map = splitQuery(response.toString());
System.out.println("response---->>: "+response.toString());
System.out.println("Status: "+(String) map.get("status"));
System.out.println("Message: "+(String) map.get("message"));
//Changed by samadhan on 24/12/2015 for check status start
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();
if(id != null)
{
......@@ -962,7 +990,6 @@ public class CommonWmsUtil {
throw new Exception(e);
//Changed by samadhan D15AKAT003 on 18/05/2015 for throw exception. End
}
}
} 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