IoT CAS Frameworks/IOT_Gateway/Device_Management_Framework/Device_Management_API/ConsumerAPI/src/java/AV_Action/AV_FrontController.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        String eventype = "";
        String data = null;
        String currIPAdd = null;
        String serverIPAdd = null;
        String cCustomer = null, Service = null;
        StringTokenizer strToken = null;
        try {
            /* TODO output your page here. You may use following sample code. */
            currIPAdd = request.getRemoteAddr();
            serverIPAdd = InetAddress.getLocalHost().getHostAddress();
            data = request.getParameter("event");
            //System.out.println("request IP Address::" + currIPAdd);
            //System.out.println("server IP Address::" + serverIPAdd);
            if ((currIPAdd.equalsIgnoreCase("127.0.0.1")) || (currIPAdd.equalsIgnoreCase(serverIPAdd))) {
                eventype = data.split(",")[0].trim();
                eventype = eventype.split("=")[1].trim();
                EventReceiverMapper.addressMap.sendEvent(eventype, data);
            } else {
                strToken = new StringTokenizer(data, ",");
                while (strToken.hasMoreTokens()) {
                    String eventypes = strToken.nextToken();
                    if (eventypes.contains("cCustomer")) {
                        cCustomer = eventypes.split("=")[1].trim();
                        //   System.out.println("cCustomer==>" + cCustomer);
                    }
                    if (eventypes.contains("service")) {
                        Service = eventypes.split("=")[1].trim();
                        //   System.out.println("Service==>" + Service);
                    }
                }
                String currID = cCustomer + "-" + Service;
                System.out.println("ID from event==" + currID);
                System.out.println("IPMap keys==" + IPMap.keySet().toString());
                if (IPMap.containsKey(currID)) {
                    if (IPMap.get(currID).toString().equalsIgnoreCase(currIPAdd)) {
                        eventype = data.split(",")[0].trim();
                        eventype = eventype.split("=")[1].trim();
                        System.out.println("Received event=" + eventype);
                        EventReceiverMapper.addressMap.sendEvent(eventype, data);
                    } else {
                        System.out.println("IP don't match, Spooring Problem");
                    }
                } else {
                    System.out.println("cust-service don't match, Spooring Problem");
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (strToken != null) {
                strToken = null;
            }
        }
    }
/**
     * 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("text/html;charset=UTF-8");
        String eventype = "";
        String data = null;
        String currIPAdd = null;
        String serverIPAdd = null;
        String cCustomer = null, Service = null;
        StringTokenizer strToken = null;
        try {
            /* TODO output your page here. You may use following sample code. */
            currIPAdd = request.getRemoteAddr();
            serverIPAdd = InetAddress.getLocalHost().getHostAddress();
            data = request.getParameter("event");
            if ((currIPAdd.equalsIgnoreCase("127.0.0.1")) || (currIPAdd.equalsIgnoreCase(serverIPAdd))) {
                eventype = data.split(",")[0].trim();
                eventype = eventype.split("=")[1].trim();
                EventReceiverMapper.addressMap.sendEvent(eventype, data);
            } else {
                strToken = new StringTokenizer(data, ",");
                while (strToken.hasMoreTokens()) {
                    String eventypes = strToken.nextToken();
                    if (eventypes.contains("cCustomer")) {
                        cCustomer = eventypes.split("=")[1].trim();
                    }
                    if (eventypes.contains("service")) {
                        Service = eventypes.split("=")[1].trim();
                    }
                }
                String currID = cCustomer + "-" + Service;
                System.out.println("ID from event==" + currID);
                System.out.println("IPMap keys==" + IPMap.keySet().toString());
                if (IPMap.containsKey(currID)) {
                    if (IPMap.get(currID).toString().equalsIgnoreCase(currIPAdd)) {
                        eventype = data.split(",")[0].trim();
                        eventype = eventype.split("=")[1].trim();
                        System.out.println("Received event=" + eventype);
                        EventReceiverMapper.addressMap.sendEvent(eventype, data);
                    } else {
                        System.out.println("IP don't match, Spooring Problem");
                    }
                } else {
                    System.out.println("cust-service don't match, Spooring Problem");
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (strToken != null) {
                strToken = null;
            }
        }
    }
protected void processRequest ( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException { response . setContentType ( "text/html;charset=UTF-8" ) ; String eventype = "" ; String data = null ; String currIPAdd = null ; String serverIPAdd = null ; String cCustomer = null , Service = null ; StringTokenizer strToken = null ; try { /* TODO output your page here. You may use following sample code. */ currIPAdd = request . getRemoteAddr ( ) ; serverIPAdd = InetAddress . getLocalHost ( ) . getHostAddress ( ) ; data = request . getParameter ( "event" ) ; if ( ( currIPAdd . equalsIgnoreCase ( "127.0.0.1" ) ) || ( currIPAdd . equalsIgnoreCase ( serverIPAdd ) ) ) { eventype = data . split ( "," ) [ 0 ] . trim ( ) ; eventype = eventype . split ( "=" ) [ 1 ] . trim ( ) ; EventReceiverMapper . addressMap . sendEvent ( eventype , data ) ; } else { strToken = new StringTokenizer ( data , "," ) ; while ( strToken . hasMoreTokens ( ) ) { String eventypes = strToken . nextToken ( ) ; if ( eventypes . contains ( "cCustomer" ) ) { cCustomer = eventypes . split ( "=" ) [ 1 ] . trim ( ) ; } if ( eventypes . contains ( "service" ) ) { Service = eventypes . split ( "=" ) [ 1 ] . trim ( ) ; } } String currID = cCustomer + "-" + Service ; System . out . println ( "ID from event==" + currID ) ; System . out . println ( "IPMap keys==" + IPMap . keySet ( ) . toString ( ) ) ; if ( IPMap . containsKey ( currID ) ) { if ( IPMap . get ( currID ) . toString ( ) . equalsIgnoreCase ( currIPAdd ) ) { eventype = data . split ( "," ) [ 0 ] . trim ( ) ; eventype = eventype . split ( "=" ) [ 1 ] . trim ( ) ; System . out . println ( "Received event=" + eventype ) ; EventReceiverMapper . addressMap . sendEvent ( eventype , data ) ; } else { System . out . println ( "IP don't match, Spooring Problem" ) ; } } else { System . out . println ( "cust-service don't match, Spooring Problem" ) ; } } } catch ( Exception e ) { e . printStackTrace ( ) ; } finally { if ( strToken != null ) { strToken = null ; } } }
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 .
//System.out.println("request IP Address::" + currIPAdd); //System.out.println("server IP Address::" + serverIPAdd); //   System.out.println("cCustomer==>" + cCustomer); //   System.out.println("Service==>" + Service);