HttpServletResponse response) {
HashMap<String, String> httpHeaderMap = new HashMap<String, String>();
httpHeaderMap.put("Content-type" , "application/json; charset=utf-8");
String accessToken=(String)request.getSession().getAttribute("AccessToken");
StringBuffer sb = new StringBuffer(APIURLUtils.getUrl("querycredittop"));
Map<String, Object[]> parameterMap = request.getParameterMap();
sb.append("?").append("accessToken=").append(accessToken);
Iterator<Entry<String, Object[]>> iterator = parameterMap.entrySet().iterator();
while(iterator.hasNext()){
Entry<String, Object[]> entry = iterator.next();
if(!"method".equals(entry.getKey())){
try {
if(entry.getValue()[0].toString()!=""){
sb.append("&").append(entry.getKey()).append("=").append(URLEncoder.encode(entry.getValue()[0].toString(),"utf-8"));
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}
HttpClient client = new DefaultHttpClient();
try {
String rp = HttpClientUtils.getResponseFromGetMethod(client,sb.toString(), "utf-8");
StringBuffer sb1 = new StringBuffer(APIURLUtils.getUrl("getStbDevice"));
sb1.append("?").append("accessToken=").append(accessToken);
sb1.append("&serviceCapability=").append("2").append("&hasLogicValue=").append("0");
String partnerId = (String) request.getSession().getAttribute(SessionInfo.PARTNERID.toString());
if(Integer.parseInt(partnerId)!=0){
sb1.append("&vspId=").append(partnerId);
}
String rpstr = HttpClientUtils.getResponseFromGetMethod(client,sb1.toString(), "utf-8");
System.out.println(rpstr);
JSONObject node = JSONObject.fromObject(rp);
JSONArray jsons = JSONArray.fromObject(node.get("data"));
JSONObject nodes = JSONObject.fromObject(rpstr);
JSONArray jsonsobs = JSONArray.fromObject(nodes.get("stbDeviceList"));
JSONArray sonjsonsobs=new JSONArray();
for (Object o1 : jsons){
JSONObject jsonNode1 = JSONObject.fromObject(o1);
String devicecode=jsonNode1.getString("deviceCode");
for (Object o : jsonsobs)
{
JSONObject jsonNode = JSONObject.fromObject(o);
if(devicecode.equals(jsonNode.getString("deviceCode"))){
sonjsonsobs.add(jsonNode);
}
}
}
jsonsobs.removeAll(sonjsonsobs);
String finalstr="{"+"stbDeviceList:"+jsonsobs.toString()+"}";
return finalstr;
} catch (Exception e) {
e.printStackTrace();
return null;
}
HashMap<String, String> httpHeaderMap = new HashMap<String, String>();
httpHeaderMap.put("Content-type" , "application/json; charset=utf-8");
String accessToken=(String)request.getSession().getAttribute("AccessToken");
StringBuffer sb = new StringBuffer(APIURLUtils.getUrl("querycredittop"));
Map<String, Object[]> parameterMap = request.getParameterMap();
sb.append("?").append("accessToken=").append(accessToken);
Iterator<Entry<String, Object[]>> iterator = parameterMap.entrySet().iterator();
while(iterator.hasNext()){
Entry<String, Object[]> entry = iterator.next();
if(!"method".equals(entry.getKey())){
try {
if(entry.getValue()[0].toString()!=""){
sb.append("&").append(entry.getKey()).append("=").append(URLEncoder.encode(entry.getValue()[0].toString(),"utf-8"));
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}
HttpClient client = new DefaultHttpClient();
try {
String rp = HttpClientUtils.getResponseFromGetMethod(client,sb.toString(), "utf-8");
StringBuffer sb1 = new StringBuffer(APIURLUtils.getUrl("getStbDevice"));
sb1.append("?").append("accessToken=").append(accessToken);
sb1.append("&serviceCapability=").append("2").append("&hasLogicValue=").append("0");
String partnerId = (String) request.getSession().getAttribute(SessionInfo.PARTNERID.toString());
if(Integer.parseInt(partnerId)!=0){
sb1.append("&vspId=").append(partnerId);
}
String rpstr = HttpClientUtils.getResponseFromGetMethod(client,sb1.toString(), "utf-8");
System.out.println(rpstr);
JSONObject node = JSONObject.fromObject(rp);
JSONArray jsons = JSONArray.fromObject(node.get("data"));
JSONObject nodes = JSONObject.fromObject(rpstr);
JSONArray jsonsobs = JSONArray.fromObject(nodes.get("stbDeviceList"));
JSONArray sonjsonsobs=new JSONArray();
for (Object o1 : jsons){
JSONObject jsonNode1 = JSONObject.fromObject(o1);
String devicecode=jsonNode1.getString("deviceCode");
for (Object o : jsonsobs)
{
JSONObject jsonNode = JSONObject.fromObject(o);
if(devicecode.equals(jsonNode.getString("deviceCode"))){
sonjsonsobs.add(jsonNode);
}
}
}
jsonsobs.removeAll(sonjsonsobs);
String finalstr="{"+"stbDeviceList:"+jsonsobs.toString()+"}";
return finalstr;
} catch (Exception e) {
e.printStackTrace();
return null;
}