List of usage examples for org.json.simple JSONArray toJSONString
public String toJSONString()
From source file:com.imagelake.android.lightbox.Servlet_LightBox.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { PrintWriter out = response.getWriter(); String type = request.getParameter("type"); System.out.println("type :" + type); JSONArray box_list = new JSONArray(); if (type != null) { type_id = Integer.parseInt(type); if (type_id == LOAD_LIGHTBOX) { String userId = request.getParameter("user_id"); System.out.println("user id :" + userId); if (userId != null) { user_id = Integer.parseInt(userId); Cart c = cdi.getCart(user_id); if (c != null) { System.out.println("cart :" + c.getCart_id()); List<CartHasImages> list = new CartDAOImp().listUserCartHasImages(c.getCart_id(), 2); if (!list.isEmpty()) { for (CartHasImages ca : list) { im = idi.getImageDetail(ca.getImg_id()); //ims=idi.getSubImage(ca.getSubimg_id()); if (im.getImage_state_image_state_id() == 1 && im.getImage_state_image_state_id() != 3) { JSONObject jo = new JSONObject(); jo.put("cart_id", ca.getCart_has_images_id()); jo.put("title", im.getTitle()); jo.put("date", ca.getDate()); jo.put("state", im.getImage_state_image_state_id()); box_list.add(jo); } else if (im.getImage_state_image_state_id() == 5 && im.getImage_state_image_state_id() != 3) { JSONObject jo = new JSONObject(); jo.put("cart_id", ca.getCart_has_images_id()); jo.put("title", im.getTitle()); jo.put("date", ca.getDate()); jo.put("state", im.getImage_state_image_state_id()); box_list.add(jo); }//from w ww. ja v a 2 s.c o m } System.out.println(box_list.toJSONString()); out.write("json=" + box_list.toJSONString()); } else { out.write("msg=No item found."); } } else { } } else { out.write("msg=Internal server error,please try agin later."); } //List<CartHasImages> list=new CartDAOImp().listUserCartHasImages(c.getCart_id(),1); } else if (type_id == LOAD_DATE) { String userId = request.getParameter("user_id"); if (userId != null) { user_id = Integer.parseInt(userId); Cart c = new CartDAOImp().getCart(user_id); if (c != null) { System.out.println("cart :" + c.getCart_id()); List<CartHasImages> list = new CartDAOImp().sortByDate(2, "DESC", c.getCart_id(), "date"); if (!list.isEmpty()) { for (CartHasImages ca : list) { im = idi.getImageDetail(ca.getImg_id()); ims = idi.getSubImage(ca.getSubimg_id()); if (im.getImage_state_image_state_id() == 1 && im.getImage_state_image_state_id() != 3) { JSONObject jo = new JSONObject(); jo.put("cart_id", ca.getCart_has_images_id()); jo.put("title", im.getTitle()); jo.put("date", ca.getDate()); jo.put("state", im.getImage_state_image_state_id()); box_list.add(jo); } else if (im.getImage_state_image_state_id() == 5 && im.getImage_state_image_state_id() != 3) { JSONObject jo = new JSONObject(); jo.put("cart_id", ca.getCart_has_images_id()); jo.put("title", im.getTitle()); jo.put("date", ca.getDate()); jo.put("state", im.getImage_state_image_state_id()); box_list.add(jo); } } System.out.println(box_list.toJSONString()); out.write("json=" + box_list.toJSONString()); } else { out.write("msg=No item found."); } } } else { out.write("msg=Internal server error,please try agin later."); } } } else { out.write("msg=Internal server error,please try agin later."); } }
From source file:main.MainClass.java
private void MEDCSup_WOE_SummGen(String mode, String mailId) { loggerObj.log(Level.INFO, "Inside MEDCSup_WOE_SummGen method"); String departmentConfigFile = "./conf/MEDC_WOESummGen/departmentDetails.conf"; JSONObject deptConfFileDetails = FileOperations.MEDC_WOE_DeptDetails(departmentConfigFile); System.out.println(deptConfFileDetails.toJSONString()); Set<String> deptKeys = deptConfFileDetails.keySet(); //String departmentName = null; for (Iterator deptItr = deptKeys.iterator(); deptItr.hasNext();) { String deptName = (String) deptItr.next(); String confFileName = (String) deptConfFileDetails.get(deptName); confFileName = confFileName.replaceAll("\\\\", ""); System.out.println(deptName + " : " + confFileName); loggerObj.log(Level.INFO, "Department: " + deptName + "conffileName: " + confFileName); JSONObject supDetails = initializeSupportDetails(confFileName); if (supDetails == null) { loggerObj.log(Level.SEVERE, "Problem in parsing " + confFileName + "to get support.zoho.com details"); return; }/*from www . j a v a 2s . co m*/ String[] responseString = null; String folderwriteResponse = null; if (mode.equals("external")) { folderwriteResponse = "./fromServer/MEDC_WOESummGen"; } if (mode.equals("internal")) { folderwriteResponse = "./TestFiles/fromServer/MEDC_WOESummGen/DesktopCentral/test_input_1"; } responseString = getSupportDataWithConfigDetails(supDetails, mode, folderwriteResponse, false, "MEDCWOETickets"); deferenceObjects(new Object[] { departmentConfigFile, supDetails }); if (responseString == null) { loggerObj.log(Level.SEVERE, "Response data from MEMDM support.zoho.com while retrieving ticket id is empty/null"); return; } String folderToReadFrom = responseString[0]; Integer index = Integer.parseInt(responseString[1]); loggerObj.log(Level.INFO, "The details obtained from support is: index: " + index + " folderToreadFrom: " + folderToReadFrom); String fileToWriteParsedResponse = "./parsed_output/MEDC_WOESummGen/" + deptName.substring(0, 4) + "_" + getCurrTimeInDD_MM_YY_HH_MM_SS() + ".json"; JSONOperations parserObj = new JSONOperations(); String currentFileToreadResponse = null; boolean isProperResponse = true; JSONArray WOESummary = null; for (int i = 1; i <= index; i++) { System.out.println("index: " + i); currentFileToreadResponse = folderToReadFrom + i + ".json"; loggerObj.log(Level.INFO, "Goid to read from the file " + currentFileToreadResponse); Object ResponseObjectFromFile = FileOperations.readFromJSONFile(currentFileToreadResponse); if (ResponseObjectFromFile instanceof JSONObject) { WOESummary = parserObj.WOESummGenForResponseJSONObject((JSONObject) ResponseObjectFromFile, deptName, WOESummary, "row"); System.out.println(WOESummary.toJSONString()); } else { isProperResponse = false; break; } } if (!isProperResponse) { System.out.println("Error is parsing JSONResponse file from MEDC support"); loggerObj.log(Level.INFO, "Error is parsing the file " + currentFileToreadResponse); return; } //JSONArray WOESummary = parserObj.WOESummGenForResponseArray(ResponseJSONArray, departmentName); if (WOESummary == null) { System.out.println( "Error in converting JSON files in the folder" + folderToReadFrom + " to parsed response"); loggerObj.log(Level.INFO, "Error in converting JSON files in the folder" + folderToReadFrom + " to parsed response"); } //System.out.println(WOESummary.toJSONString()); boolean isFileWriteSucess = FileOperations.writeObjectToFile(WOESummary, fileToWriteParsedResponse); if (!isFileWriteSucess) { loggerObj.log(Level.INFO, "Error in writting the responseJSONArray to the file " + fileToWriteParsedResponse); } loggerObj.log(Level.INFO, "Parsed response is written to" + fileToWriteParsedResponse); String[] status = { "Need to Analyze", "Needs to Call", "Waiting on Engineering" }; String[] MsgMultiPartContent = createMsgContentForWOE_Tickets(WOESummary, status); loggerObj.log(Level.INFO, "Mail content is created for parsed response"); String subject = deptName + " tickets for developers"; System.out.println("Tickets processed..Going to send mail. This might take around 2 to 3 mins"); int indexOFLastSlash = confFileName.lastIndexOf("/"); String mailsettingsConf = confFileName.substring(0, indexOFLastSlash) + "/mailsettings.conf"; JSONObject mailSettings = FileOperations.mailSettingsToJO(mailsettingsConf); loggerObj.log(Level.INFO, "The mailsettings conf received from the file " + mailsettingsConf + " is " + mailSettings.toJSONString()); mailId = (String) mailSettings.get("Senderemailaddress"); if (mailId == null) { loggerObj.log(Level.SEVERE, "The mailId obtained from the conf file " + mailsettingsConf + " empty"); return; } String isMailSentProperly = MailOperations.sendMail(mailId, MsgMultiPartContent, subject); if (isMailSentProperly != null) { System.out.println(isMailSentProperly); if (isMailSentProperly.contains("Could not connect to SMTP host") || isMailSentProperly.contains("Unknown SMTP host")) { System.out.println("Mail server not reachable"); loggerObj.log(Level.INFO, "Mail server not reachable"); } if (isMailSentProperly.equals("Content is null")) { loggerObj.log(Level.INFO, "MsgMultiPartContent generated to give to mail api is empty or not proper"); } } System.out.println("***********************************************************"); } }
From source file:be.iminds.aiolos.ui.DemoServlet.java
private void getRepositoryBundles(PrintWriter writer) { JSONArray components = new JSONArray(); Repository[] repos = new Repository[] {}; repos = repositoryTracker.getServices(repos); for (Repository repo : repos) { try {/*from w w w . j av a 2 s . com*/ CapabilityRequirementImpl requirement = new CapabilityRequirementImpl("osgi.identity", null); requirement.addDirective("filter", String.format("(%s=%s)", "osgi.identity", "*")); Map<Requirement, Collection<Capability>> result = repo .findProviders(Collections.singleton(requirement)); for (Capability c : result.values().iterator().next()) { String type = (String) c.getAttributes().get("type"); if (type != null && type.equals("osgi.bundle")) { String componentId = (String) c.getAttributes().get("osgi.identity"); String version = c.getAttributes().get("version").toString(); String name = null; String description = null; try { RepositoryContent content = (RepositoryContent) c.getResource(); JarInputStream jar = new JarInputStream(content.getContent()); Manifest mf = jar.getManifest(); Attributes attr = mf.getMainAttributes(); name = attr.getValue("Bundle-Name"); description = attr.getValue("Bundle-Description"); } catch (Exception e) { e.printStackTrace(); } JSONObject component = new JSONObject(); component.put("componentId", componentId); component.put("version", version); component.put("name", name); component.put("description", description); components.add(component); } } } catch (Exception e) { } } writer.write(components.toJSONString()); }
From source file:mml.handler.get.MMLGetVersionsHandler.java
/** * Get the version listing from the MVD//from ww w. j a v a 2 s . co m * @param request the request * @param response the response * @param urn the remaining urn being empty * @throws MMLException */ public void handle(HttpServletRequest request, HttpServletResponse response, String urn) throws MMLException { try { String docid = request.getParameter(Params.DOCID); if (docid == null) throw new Exception("You must specify a docid parameter"); AeseResource res = doGetResource(Database.CORTEX, docid); JSONArray jVersions = new JSONArray(); if (res != null) { String[] versions = res.listVersions(); HashMap<String, JSONObject> vSet = new HashMap<String, JSONObject>(); for (int i = 0; i < versions.length; i++) { String base = Layers.stripLayer(versions[i]); JSONObject jObj = vSet.get(base); if (jObj == null) jObj = new JSONObject(); String upgraded = Layers.upgradeLayerName(versions, versions[i]); if (!upgraded.equals(versions[i])) { JSONArray repl = (JSONArray) jObj.get("replacements"); if (repl == null) { repl = new JSONArray(); jObj.put("replacements", repl); } JSONObject entry = new JSONObject(); entry.put("old", versions[i]); entry.put("new", upgraded); repl.add(entry); } if (upgraded.endsWith("layer-final")) jObj.put("desc", res.getVersionLongName(i + 1)); // add the layer names if (upgraded.endsWith("layer-final") || upgraded.matches(".*layer-[0-9]+$")) { JSONArray jArr = (JSONArray) jObj.get("layers"); if (jArr == null) jArr = new JSONArray(); int index = upgraded.lastIndexOf("layer"); String layerName = upgraded.substring(index); if (!jArr.contains(layerName)) jArr.add(layerName); if (!jObj.containsKey("layers")) jObj.put("layers", jArr); } if (!vSet.containsKey(base)) vSet.put(base, jObj); } // convert hashmap to array Set<String> keys = vSet.keySet(); Iterator<String> iter = keys.iterator(); while (iter.hasNext()) { String version = iter.next(); JSONObject jObj = vSet.get(version); jObj.put("vid", version); jVersions.add(jObj); } } response.setContentType("application/json"); response.setCharacterEncoding(encoding); String jStr = jVersions.toJSONString().replaceAll("\\\\/", "/"); response.getWriter().println(jStr); } catch (Exception e) { throw new MMLException(e); } }
From source file:com.imagelake.android.downloadhistory.Servlet_downloadhistory.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { PrintWriter out = response.getWriter(); String type_id = request.getParameter("type"); JSONArray box_list = new JSONArray(); if (type_id != null) { type = Integer.parseInt(type_id); String userId = request.getParameter("user_id"); if (userId != null) { user_id = Integer.parseInt(userId); c = cdi.getCart(user_id);/*from ww w . ja v a 2 s . c o m*/ if (c != null) { if (type == LOAD_DOWNLOAD_HISTORY) { System.out.println("cart :" + c.getCart_id()); List<CartHasImages> list = new CartDAOImp().listUserCartHasImages(c.getCart_id(), 1); if (!list.isEmpty()) { for (CartHasImages ca : list) { im = idi.getImageDetail(ca.getImg_id()); // ims=idi.getSubImage(ca.getSubimg_id()); if (im.getImage_state_image_state_id() == 1 && im.getImage_state_image_state_id() != 3) { JSONObject jo = new JSONObject(); jo.put("cart_id", ca.getCart_has_images_id()); jo.put("title", im.getTitle()); jo.put("sub_id", ca.getSubimg_id()); jo.put("date", ca.getDate()); jo.put("credits", ca.getCredits()); jo.put("state", im.getImage_state_image_state_id()); box_list.add(jo); } else if (im.getImage_state_image_state_id() == 5 && im.getImage_state_image_state_id() != 3) { JSONObject jo = new JSONObject(); jo.put("cart_id", ca.getCart_has_images_id()); jo.put("title", im.getTitle()); jo.put("sub_id", ca.getSubimg_id()); jo.put("date", ca.getDate()); jo.put("credits", ca.getCredits()); jo.put("state", im.getImage_state_image_state_id()); box_list.add(jo); } } System.out.println(box_list.toJSONString()); out.write("json=" + box_list.toJSONString()); } else { out.write("msg=No item found."); } } else if (type == LOAD_DATE) { System.out.println("cart :" + c.getCart_id()); List<CartHasImages> list = new CartDAOImp().sortByDate(1, "DESC", c.getCart_id(), "date"); if (!list.isEmpty()) { for (CartHasImages ca : list) { im = idi.getImageDetail(ca.getImg_id()); // ims=idi.getSubImage(ca.getSubimg_id()); if (im.getImage_state_image_state_id() == 1 && im.getImage_state_image_state_id() != 3) { JSONObject jo = new JSONObject(); jo.put("cart_id", ca.getCart_has_images_id()); jo.put("title", im.getTitle()); jo.put("sub_id", ca.getSubimg_id()); jo.put("date", ca.getDate()); jo.put("credits", ca.getCredits()); jo.put("state", im.getImage_state_image_state_id()); box_list.add(jo); } else if (im.getImage_state_image_state_id() == 5 && im.getImage_state_image_state_id() != 3) { JSONObject jo = new JSONObject(); jo.put("cart_id", ca.getCart_has_images_id()); jo.put("title", im.getTitle()); jo.put("sub_id", ca.getSubimg_id()); jo.put("date", ca.getDate()); jo.put("credits", ca.getCredits()); jo.put("state", im.getImage_state_image_state_id()); box_list.add(jo); } } System.out.println(box_list.toJSONString()); out.write("json=" + box_list.toJSONString()); } else { out.write("msg=No item found."); } } else if (type == LOAD_SIZE) { System.out.println("cart :" + c.getCart_id()); List<CartHasImages> list = new CartDAOImp().sortByDate(1, "ASC", c.getCart_id(), "credits"); if (!list.isEmpty()) { for (CartHasImages ca : list) { im = idi.getImageDetail(ca.getImg_id()); // ims=idi.getSubImage(ca.getSubimg_id()); if (im.getImage_state_image_state_id() == 1 && im.getImage_state_image_state_id() != 3) { JSONObject jo = new JSONObject(); jo.put("cart_id", ca.getCart_has_images_id()); jo.put("title", im.getTitle()); jo.put("sub_id", ca.getSubimg_id()); jo.put("date", ca.getDate()); jo.put("credits", ca.getCredits()); jo.put("state", im.getImage_state_image_state_id()); box_list.add(jo); } else if (im.getImage_state_image_state_id() == 5 && im.getImage_state_image_state_id() != 3) { JSONObject jo = new JSONObject(); jo.put("cart_id", ca.getCart_has_images_id()); jo.put("title", im.getTitle()); jo.put("sub_id", ca.getSubimg_id()); jo.put("date", ca.getDate()); jo.put("credits", ca.getCredits()); jo.put("state", im.getImage_state_image_state_id()); box_list.add(jo); } } System.out.println(box_list.toJSONString()); out.write("json=" + box_list.toJSONString()); } else { out.write("msg=No item found."); } } } } else { out.write("msg=Internal server error,please try agin later."); } } else { out.write("msg=Internal server error,please try agin later."); } }
From source file:com.imagelake.control.UserDAOImp.java
public String getSubadminList() { JSONArray all = new JSONArray(); JSONArray user = new JSONArray(); JSONArray page = new JSONArray(); String re = ""; try {/*from w w w . j a v a 2 s . co m*/ String sql = "SELECT * FROM user WHERE user_type_user_type_id > 3 "; PreparedStatement ps = DBFactory.getConnection().prepareStatement(sql); ResultSet rs = ps.executeQuery(); while (rs.next()) { JSONObject jo = new JSONObject(); jo.put("id", rs.getInt(1)); jo.put("user_name", rs.getString(2)); jo.put("em", rs.getString(5)); jo.put("phn", rs.getString(12)); jo.put("state", rs.getInt(19)); jo.put("type", getAdminUserType(rs.getInt(21))); jo.put("type_id", rs.getInt(21)); user.add(jo); } rs.close(); String sql2 = "SELECT state FROM interfaces WHERE url=?"; ps = DBFactory.getConnection().prepareStatement(sql2); ps.setString(1, "RegAdmin.jsp"); rs = ps.executeQuery(); JSONObject jo2 = new JSONObject(); while (rs.next()) { jo2.put("regstate", rs.getInt(1)); } rs.close(); String sql3 = "SELECT state FROM interfaces WHERE url=?"; ps = DBFactory.getConnection().prepareStatement(sql2); ps.setString(1, "UpdateAdmin.jsp"); rs = ps.executeQuery(); JSONObject jo3 = new JSONObject(); while (rs.next()) { jo3.put("upstate", rs.getInt(1)); } rs.close(); all.add(user); all.add(jo2); all.add(jo3); re = "json=" + all.toJSONString(); } catch (Exception e) { e.printStackTrace(); re = "msg=Internal server error,Please try again later."; } return re; }
From source file:com.caspida.plugins.graph.EntityGraphNeo4jPlugin.java
@Name(EntityGraphConstants.API_GET_USER_PST) @Description("Get a users's PST model") @PluginTarget(GraphDatabaseService.class) public String getUserPst(@Source GraphDatabaseService graphDb, @Description("user id ") @Parameter(name = "userId") String userId) { JSONArray nodes = new JSONArray(); Node node = null;/*from w w w . j a va 2 s . c om*/ Label pstLabel = DynamicLabel.label("PST___Root"); logger.error("Got user id {}", userId); try (Transaction txn = graphDb.beginTx()) { // find the node // use the label first ResourceIterable<Node> iterableNodes = graphDb.findNodesByLabelAndProperty(pstLabel, EntityGraphConstants.REQ_USER_ID_TAG, userId); if (iterableNodes != null) { ResourceIterator<Node> it = iterableNodes.iterator(); if (it.hasNext()) { node = it.next(); } } logger.debug("Found node {}", node); if (node == null) { logger.error("Can not find node with id {}", userId); return nodes.toString(); } Iterable<Relationship> rels = node.getRelationships(); for (Relationship rel : rels) { Node childNode = (rel.getStartNode().getId() == node.getId()) ? rel.getEndNode() : rel.getStartNode(); Object key = childNode.getProperty(EntityGraphConstants.NODE_NAME); if (key == null) { continue; } JSONObject childInfo = walkPSTGraph(childNode, node, rel); if (childInfo != null) { nodes.add(childInfo); } } } return nodes.toJSONString(); }
From source file:com.caspida.plugins.graph.EntityGraphNeo4jPlugin.java
@Name(EntityGraphConstants.API_GET_ENTITY_PST) @Description("Get an entity's PST model") @PluginTarget(GraphDatabaseService.class) public String getEntityPst(@Source GraphDatabaseService graphDb, @Description("entity id and entity type") @Parameter(name = "entityId") String entityId, @Parameter(name = "entityType") String entityType) { JSONArray nodes = new JSONArray(); Node node = null;//w w w . jav a 2 s .c om Label pstLabel = DynamicLabel.label("PST___Root"); logger.error("Got entity id {}", entityId); String property = EntityGraphConstants.REQ_USER_ID_TAG; logger.error("Got property {}", property); try (Transaction txn = graphDb.beginTx()) { // find the node // use the label first ResourceIterable<Node> iterableNodes = graphDb.findNodesByLabelAndProperty(pstLabel, property, entityId); if (iterableNodes != null) { ResourceIterator<Node> it = iterableNodes.iterator(); if (it.hasNext()) { node = it.next(); } } logger.debug("Found node {}", node); if (node == null) { logger.error("Can not find node with id {}", entityId); return nodes.toString(); } Iterable<Relationship> rels = node.getRelationships(); for (Relationship rel : rels) { Node childNode = (rel.getStartNode().getId() == node.getId()) ? rel.getEndNode() : rel.getStartNode(); Object key = childNode.getProperty(EntityGraphConstants.NODE_NAME); if (key == null) { continue; } JSONObject childInfo = walkPSTGraph(childNode, node, rel); if (childInfo != null) { nodes.add(childInfo); } } } return nodes.toJSONString(); }
From source file:net.sourceforge.fenixedu.domain.student.Registration.java
@SuppressWarnings("unchecked") public static String readAllStudentsInfoForJobBank() { ExecutionYear currentExecutionYear = ExecutionYear.readCurrentExecutionYear(); Set<Registration> registrations = new HashSet<Registration>(); LocalDate today = new LocalDate(); for (Registration registration : Bennu.getInstance().getRegistrationsSet()) { if (registration.hasAnyActiveState(currentExecutionYear) && registration.isBolonha() && !registration.getDegreeType().equals(DegreeType.EMPTY)) { registrations.add(registration); }//w w w . j a va2 s . c o m } for (ConclusionProcess conclusionProcess : Bennu.getInstance().getConclusionProcessesSet()) { if (conclusionProcess.getConclusionDate() != null && !conclusionProcess.getConclusionDate().plusYears(1).isBefore(today)) { registrations.add(conclusionProcess.getRegistration()); } } JSONArray infos = new JSONArray(); for (Registration registration : registrations) { infos.add(getStudentInfoForJobBank(registration)); } return infos.toJSONString(); }
From source file:com.cabserver.handler.Admin.java
@GET @Path("drivers/list/company") @Produces(MediaType.TEXT_HTML)/*from w ww . j a v a 2s . c o m*/ public Response getCompanyDriversList() { JSONArray arryTM = new JSONArray(); try { TravelMaster tm = new TravelMaster(); ArrayList<DriverMaster> driverMasterArryList = DatabaseManager.getAllCompanyDriverDetails(); for (DriverMaster tmpDm : driverMasterArryList) { JSONObject obj1 = new JSONObject(); obj1.put("code", "200"); obj1.put("msg", "Drivers list fetched."); obj1.put("driverId", tmpDm.getDriverId()); obj1.put("firstName", tmpDm.getFirstName()); obj1.put("lastName", tmpDm.getLastName()); obj1.put("phone", tmpDm.getPhoneNumber()); obj1.put("age", tmpDm.getAge() + ""); obj1.put("sex", tmpDm.getSex()); obj1.put("licNumber", tmpDm.getDriverLicense()); obj1.put("address", tmpDm.getAddress()); obj1.put("currAddress", tmpDm.getCurrAddr()); obj1.put("driverStatus", tmpDm.getDriverStatus()); obj1.put("driverCategory", tmpDm.getDriverCategory()); arryTM.add(obj1); } } catch (Exception e) { e.printStackTrace(); } if (arryTM.size() < 1) { /* * log.info("getCompanyDriversList >> Drivers search ErrorCcode is " * + Constants.BOOKING_FAILED_CODE + "."); */ JSONObject obj1 = new JSONObject(); obj1.put("code", ConfigDetails.constants.get("BOOKING_FAILED_CODE")); obj1.put("msg", "Drivers list not found."); arryTM.add(obj1); return Response.status(200).entity(arryTM.toJSONString()).build(); } else { return Response.status(200).entity(arryTM.toJSONString()).build(); } }