uk.ac.cam.acr31.android.geomessaging.servertools
Class ServerHelper

java.lang.Object
  extended by uk.ac.cam.acr31.android.geomessaging.servertools.ServerHelper

public class ServerHelper
extends java.lang.Object

A helper class of static methods for interacting with the GeoMessagingServer

Author:
acr31

Nested Class Summary
private static class ServerHelper.MyXMLHandler
          Helper class to parse the XML response from the server
 
Field Summary
private static java.lang.String URL_MESSAGE_LIST
          URL to use to query for the list of nearby messages
private static java.lang.String URL_PICTURE_FOLDER
          The URL to prefix onto image names to download them from the web
private static java.lang.String URL_UPLOAD
          URL to use for uploading new messages
 
Constructor Summary
ServerHelper()
           
 
Method Summary
static java.util.ArrayList<Message> getMessages(double lat, double lng, double proxMiles)
          Return a list of all the messages which have been posted at the given latitude and longitude within the chosen proximity
private static java.lang.String getResponseString(java.lang.String urlAddress, org.apache.http.entity.mime.MultipartEntity form)
          Make a POST request to the URL using the form given and return a String for the response body
private static java.io.InputStream obtainInputStream(java.lang.String urlAddress, org.apache.http.entity.mime.MultipartEntity form)
          Make a POST request to the URL using the form given and return an InputStream for the response body
static boolean sendMessage(java.lang.String message, java.lang.String pictureFilename, double lat, double lng)
          Submit this message to the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URL_UPLOAD

private static final java.lang.String URL_UPLOAD
URL to use for uploading new messages

See Also:
Constant Field Values

URL_MESSAGE_LIST

private static final java.lang.String URL_MESSAGE_LIST
URL to use to query for the list of nearby messages

See Also:
Constant Field Values

URL_PICTURE_FOLDER

private static final java.lang.String URL_PICTURE_FOLDER
The URL to prefix onto image names to download them from the web

See Also:
Constant Field Values
Constructor Detail

ServerHelper

public ServerHelper()
Method Detail

obtainInputStream

private static java.io.InputStream obtainInputStream(java.lang.String urlAddress,
                                                     org.apache.http.entity.mime.MultipartEntity form)
                                              throws org.apache.http.client.ClientProtocolException,
                                                     java.io.IOException
Make a POST request to the URL using the form given and return an InputStream for the response body

Throws:
org.apache.http.client.ClientProtocolException
java.io.IOException

getResponseString

private static java.lang.String getResponseString(java.lang.String urlAddress,
                                                  org.apache.http.entity.mime.MultipartEntity form)
                                           throws org.apache.http.client.ClientProtocolException,
                                                  java.io.IOException
Make a POST request to the URL using the form given and return a String for the response body

Throws:
org.apache.http.client.ClientProtocolException
java.io.IOException

getMessages

public static java.util.ArrayList<Message> getMessages(double lat,
                                                       double lng,
                                                       double proxMiles)
Return a list of all the messages which have been posted at the given latitude and longitude within the chosen proximity


sendMessage

public static boolean sendMessage(java.lang.String message,
                                  java.lang.String pictureFilename,
                                  double lat,
                                  double lng)
Submit this message to the server.

Parameters:
message - is the text of the message to submit
pictureFileName - is the filename of a file on the phone's storage containing the image to include
lat - is the latitude of the current location
lng - is the longitude of the current location