IoT CAS Frameworks/IOT_Server/Server_Admin_Framework/source/ConsumerAPI/src/java/AV_Action/AV_GetCustomers.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        response.setContentType("application/json;charset=UTF-8");
        PrintWriter out = response.getWriter();
        StringBuffer result = new StringBuffer();
        String custInfo = null;
       
        try {
            
            //added by ananddw for Device Managment
             Connection con = DatabaseConnection.getAVSAConnection(request);
             custInfo=new DeviceManagment().getCustomers(con).toString();
             
             
             if (custInfo == null) {
                log.debug("No data found");
                result.append("{\"error\":\"error\"}");
            }
             
            /**
            custInfo = GetCustomers.getCustomerInfo(request);
            if (custInfo == null) {
                log.debug("No data found");
                result.append("{\"error\":\"error\"}");
            } else {
                if (custInfo.equals("null")) {
                    custInfo = "[]";
                } else {
                    custInfo = "[" + custInfo + "]";
                }  
            }
            **/
            
            String callback = request.getParameter("callback");
            result.append(callback + "('" + custInfo + "')");
            //System.out.println("Response==>" + result);
            con.close();
        } catch (Exception e) {
            e.printStackTrace();
            log.error("Error while performing action", e);
        }
        try {
            response.getWriter().write(result.toString());
        } catch (Exception e) {
            log.debug("Exception while writing output", e);
        } finally {
            try {
                result = null;
                custInfo = null;
                if (out != null) {
                    out.close();
                    out = null;
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }
/**
     * Processes requests for both HTTP
     * <code>GET</code> and
     * <code>POST</code> methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
Processes requests for both HTTP
GET and
POST methods.

@param request servlet request
@param response servlet response
@throws ServletException if a servlet-specific error occurs
@throws IOException if an I/O error occurs
Processes requests for both HTTP GET and POST methods . @param request servlet request @param response servlet response @throws ServletException if a servlet - specific error occurs @throws IOException if an I / O error occurs
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("application/json;charset=UTF-8");
        PrintWriter out = response.getWriter();
        StringBuffer result = new StringBuffer();
        String custInfo = null;
        try {
             Connection con = DatabaseConnection.getAVSAConnection(request);
             custInfo=new DeviceManagment().getCustomers(con).toString();
             if (custInfo == null) {
                log.debug("No data found");
                result.append("{\"error\":\"error\"}");
            }
            /**
            custInfo = GetCustomers.getCustomerInfo(request);
            if (custInfo == null) {
                log.debug("No data found");
                result.append("{\"error\":\"error\"}");
            } else {
                if (custInfo.equals("null")) {
                    custInfo = "[]";
                } else {
                    custInfo = "[" + custInfo + "]";
                }  
            }
            **/
            String callback = request.getParameter("callback");
            result.append(callback + "('" + custInfo + "')");
            con.close();
        } catch (Exception e) {
            e.printStackTrace();
            log.error("Error while performing action", e);
        }
        try {
            response.getWriter().write(result.toString());
        } catch (Exception e) {
            log.debug("Exception while writing output", e);
        } finally {
            try {
                result = null;
                custInfo = null;
                if (out != null) {
                    out.close();
                    out = null;
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }
protected void processRequest ( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException { response . setContentType ( "application/json;charset=UTF-8" ) ; PrintWriter out = response . getWriter ( ) ; StringBuffer result = new StringBuffer ( ) ; String custInfo = null ; try { Connection con = DatabaseConnection . getAVSAConnection ( request ) ; custInfo = new DeviceManagment ( ) . getCustomers ( con ) . toString ( ) ; if ( custInfo == null ) { log . debug ( "No data found" ) ; result . append ( "{\"error\":\"error\"}" ) ; } /**
            custInfo = GetCustomers.getCustomerInfo(request);
            if (custInfo == null) {
                log.debug("No data found");
                result.append("{\"error\":\"error\"}");
            } else {
                if (custInfo.equals("null")) {
                    custInfo = "[]";
                } else {
                    custInfo = "[" + custInfo + "]";
                }  
            }
            **/ String callback = request . getParameter ( "callback" ) ; result . append ( callback + "('" + custInfo + "')" ) ; con . close ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; log . error ( "Error while performing action" , e ) ; } try { response . getWriter ( ) . write ( result . toString ( ) ) ; } catch ( Exception e ) { log . debug ( "Exception while writing output" , e ) ; } finally { try { result = null ; custInfo = null ; if ( out != null ) { out . close ( ) ; out = null ; } } catch ( Exception ex ) { ex . printStackTrace ( ) ; } } }
Processes requests for both HTTP
 <code>GET</code> and
 <code>POST</code> methods.
Processes requests for both HTTP <code > GET< / code > and <code > POST< / code > methods .
//added by ananddw for Device Managment //System.out.println("Response==>" + result);