de.unikassel.android.sdcframework.transmission
Class SimpleHttpProtocol

Package class diagram package SimpleHttpProtocol
java.lang.Object
  extended by de.unikassel.android.sdcframework.transmission.AbstractProtocol
      extended by de.unikassel.android.sdcframework.transmission.SimpleHttpProtocol
All Implemented Interfaces:
ProtocolStrategy, UpdatableTransmissionComponent<TransmissionProtocolConfiguration>
Direct Known Subclasses:
BasicAuthHttpProtocol

public class SimpleHttpProtocol
extends AbstractProtocol

Implementation of a simple HTTP protocol without authentication.


Field Summary
private static String IO_EXCEPTION
          The IO exception message
private static String PROTOCOL_EXCEPTION
          The protocol exception message
 
Fields inherited from class de.unikassel.android.sdcframework.transmission.AbstractProtocol
context, FILE_NOT_FOUND, INVALID_URL, lastError, UNKNOWN_PROTCOL
 
Constructor Summary
SimpleHttpProtocol(Context context, UUID uuid, TransmissionProtocolConfiguration config)
          Constructor
 
Method Summary
protected  void configureForAuthentication(DefaultHttpClient client, URL url)
          Method to configure the client for authentication
protected  boolean doUploadFile(File file)
          Does upload a file according to the concrete protocol
private  String getContentType(String fileName)
          Method to determine the file type
private  boolean httpUpload(File file)
          Method for an HTTP upload of file stream
 
Methods inherited from class de.unikassel.android.sdcframework.transmission.AbstractProtocol
doHandleError, getAuthPassword, getContext, getFileName, getHost, getLastError, getMd5Password, getURL, getUserName, getUuid, setFileName, setLastError, setURL, updateConfiguration, uploadFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IO_EXCEPTION

private static final String IO_EXCEPTION
The IO exception message

See Also:
Constant Field Values

PROTOCOL_EXCEPTION

private static final String PROTOCOL_EXCEPTION
The protocol exception message

See Also:
Constant Field Values
Constructor Detail

SimpleHttpProtocol

public SimpleHttpProtocol(Context context,
                          UUID uuid,
                          TransmissionProtocolConfiguration config)
Constructor

Parameters:
context - the context
uuid - the unique SDC installation identifier for this device
config - the current transmission configuration
Method Detail

httpUpload

private final boolean httpUpload(File file)
Method for an HTTP upload of file stream

Parameters:
file - the input file
Returns:
true if successful, false otherwise

configureForAuthentication

protected void configureForAuthentication(DefaultHttpClient client,
                                          URL url)
Method to configure the client for authentication

Parameters:
client - the default http client instance to configure
url - the upload url

getContentType

private final String getContentType(String fileName)
Method to determine the file type

Parameters:
fileName - the file name
Returns:
the content mime type for the file

doUploadFile

protected final boolean doUploadFile(File file)
Description copied from class: AbstractProtocol
Does upload a file according to the concrete protocol

Specified by:
doUploadFile in class AbstractProtocol
Parameters:
file - the file for upload
Returns:
true if successful, false otherwise ( last error will be set in this case )