Package org.gsm.oneapi.responsebean.location

Examples of org.gsm.oneapi.responsebean.location.LocationResponse


  @param requestedAccuracy The preferred accuracy of the result, in metres. Typically, when you request an accurate location it will take longer to retrieve than a coarse location. So requestedAccuracy=10 will take longer than requestedAccuracy=100

  @see LocationResponse
   */
  public LocationResponse locateTerminal(String endUserId, int requestedAccuracy) {
    LocationResponse response=new LocationResponse();
   
    String endpoint=endPoints.getLocationEndpoint()+"?requestedAccuracy="+requestedAccuracy;
   
      int responseCode=0;
        String contentType = null;
       
    try {
     
      if (endUserId!=null) endpoint=endpoint+"&address="+URLEncoder.encode(endUserId, "utf-8");
     
      if (dumpRequestAndResponse) JSONRequest.dumpRequestVariables(endpoint, authorisationHeader, null);
     
      HttpURLConnection con = JSONRequest.setupConnection(endpoint, authorisationHeader);

          responseCode=con.getResponseCode();
            contentType = con.getContentType();
           
            response.setHTTPResponseCode(responseCode);
            response.setContentType(contentType);
         
            response=locationRequester.getResponse(con, OneAPIServlet.OK);
    } catch (Exception e) {
      logger.error("Exception "+e.getMessage()+" "+e.getLocalizedMessage());
      e.printStackTrace();
      response.setHTTPResponseCode(responseCode);
      response.setContentType(contentType);
     
      response.setRequestError(new RequestError(RequestError.SERVICEEXCEPTION, "SVCJAVA", e.getMessage(), e.getClass().getName()));
    }         
    return response;
  }
View Full Code Here


  @param requestedAccuracy The preferred accuracy of the result, in metres. Typically, when you request an accurate location it will take longer to retrieve than a coarse location. So requestedAccuracy=10 will take longer than requestedAccuracy=100

  @see LocationResponse
   */
  public LocationResponse locateMultipleTerminals(String[] endUserId, int requestedAccuracy) {
    LocationResponse response=new LocationResponse();
   
    String endpoint=endPoints.getLocationEndpoint()+"?requestedAccuracy="+requestedAccuracy;
   
      int responseCode=0;
        String contentType = null;
       
    try {
     
      if (endUserId!=null) {
        for (String address:endUserId) {
          if (address!=null) endpoint=endpoint+"&address="+URLEncoder.encode(address, "utf-8");
        }       
      }
     
      if (dumpRequestAndResponse) JSONRequest.dumpRequestVariables(endpoint, authorisationHeader, null);

      HttpURLConnection con = JSONRequest.setupConnection(endpoint, authorisationHeader);

          responseCode=con.getResponseCode();
            contentType = con.getContentType();
           
            response.setHTTPResponseCode(responseCode);
            response.setContentType(contentType);
         
            response=locationRequester.getResponse(con, OneAPIServlet.OK);
    } catch (Exception e) {
      logger.error("Exception "+e.getMessage()+" "+e.getLocalizedMessage());
      e.printStackTrace();
     
      response.setHTTPResponseCode(responseCode);
      response.setContentType(contentType);
     
      response.setRequestError(new RequestError(RequestError.SERVICEEXCEPTION, "SVCJAVA", e.getMessage(), e.getClass().getName()));
    }         
    return response;
  }
View Full Code Here

   
    logger.debug("AuthorisationHeader="+authorisationHeader);
   
    Locate me=new Locate(serviceEndpoints, authorisationHeader);
   
    LocationResponse singleResponse=me.locateTerminal("tel:123456", 1000);
   
    logger.debug("Locate single terminal");
    if (singleResponse!=null) {
      logger.debug("Have JSON response:\n"+singleResponse.toString());
      if (singleResponse.getTerminalLocationList()!=null && singleResponse.getTerminalLocationList().getTerminalLocation()!=null) {
        for (TerminalLocation t:singleResponse.getTerminalLocationList().getTerminalLocation())
          logger.debug("Location Response="+t.toString());
      }
    } else {
      logger.debug("No response obtained");
    }

    logger.debug("Make erroneous request");
    LocationResponse errorCase=me.locateTerminal(null, 1000);
   
    if (errorCase!=null) {
      logger.debug("Have JSON response:\n"+errorCase.toString());
      if (errorCase.getTerminalLocationList()!=null && errorCase.getTerminalLocationList().getTerminalLocation()!=null) {
        for (TerminalLocation t:errorCase.getTerminalLocationList().getTerminalLocation())
          logger.debug("Location Response="+t.toString());
      }
    } else {
      logger.debug("No response obtained");
    }

    logger.debug("Locate multiple terminals");
    String[] multipleAddresses={"tel:123456", "tel:987654", "tel:2468", "tel:13579"};
   
    LocationResponse multipleCase=me.locateMultipleTerminals(multipleAddresses, 50);
   
    if (multipleCase!=null) {
      logger.debug("Have JSON response:\n"+multipleCase.toString());
      if (multipleCase.getTerminalLocationList()!=null && multipleCase.getTerminalLocationList().getTerminalLocation()!=null) {
        for (TerminalLocation t:multipleCase.getTerminalLocationList().getTerminalLocation())
          logger.debug("Location Response="+t.toString());
      }
    } else {
      logger.debug("No response obtained");
    }
View Full Code Here

TOP

Related Classes of org.gsm.oneapi.responsebean.location.LocationResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.