|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.clients.util.http.MultiPartPost
Class MultiPartPost provides the capability to specify a set of files to be uploaded to
a url.
Supported API:false
Extendable:false
Nested Class Summary | |
(package private) class |
MultiPartPost.PostThread
|
Field Summary | |
(package private) static String |
BOUNDARY
|
private static int |
BUF_SIZ
|
private BufferedOutputStream |
bufferedOutput
|
private URLConnection |
connection
|
static int |
FAILURE_FILE_NOT_FOUND
Returned by getOperationFailureCode() . |
static int |
FAILURE_HTTP_ERROR
Returned by getOperationFailureCode() . |
static int |
FAILURE_IO_ERROR
Returned by getOperationFailureCode() . |
static int |
FAILURE_NONE
Returned by getOperationFailureCode() . |
private int |
fileNum
|
private int |
httpResponseCode
|
private String |
httpResponseMessage
|
private Hashtable |
listeners
|
private int |
operationStatus
|
private boolean |
postCancelled
|
private Vector |
postData
|
private URL |
url
|
Fields inherited from interface wt.clients.util.MultiPartPostIfc |
OPERATION_CANCEL, OPERATION_CANCEL_REQUEST, OPERATION_COMPLETE, OPERATION_FAILURE, OPERATION_INACTIVE, OPERATION_START |
Constructor Summary | |
MultiPartPost(URL url)
Create a MultiPartPost object. |
Method Summary | |
void |
addUploadListener(MultiPartPostListener l)
|
void |
cancelOperation()
|
void |
clear()
If connection is open close it. |
private void |
closeConnection()
|
private void |
closeOutputStream()
|
private void |
connect()
|
private String |
getContentType(String filename)
|
int |
getHTTPResponseCode()
Return the HTTP response code for the upload operation. |
String |
getHTTPResponseMessage()
|
int |
getOperationStatus()
|
int |
getResponseCode()
|
String |
getResponseString()
|
String |
getURL()
|
static void |
main(String[] args)
|
private PostEntry |
newPostEntry(int type,
String name,
String value)
|
private void |
openConnection()
Open the connection and set headers. |
private void |
operationProgress(String contentName,
String path,
int byteCount)
|
private void |
operationStatusChange(int newStatus)
|
private String |
parseExtension(String path)
|
private int |
parseHTTPResponse()
Return HTTP reponse code. |
Thread |
performOperation(boolean separateThread)
Perform the multi part post operation. |
private void |
printData(PostEntry postEntry)
|
private void |
printFileHeader(PostEntry postEntry)
|
private void |
println(String s)
|
void |
removeUploadListener(MultiPartPostListener l)
|
void |
setData(String contentName,
String value)
Record data to be posted. |
private void |
setHTTPResponseCode(int code)
|
(package private) void |
setHTTPResponseMessage(String message)
|
private void |
setOperationStatus(int newValue)
|
void |
setPath(String contentName,
String path)
Record file to be posted. |
private void |
showResponse(InputStream input)
|
private void |
streamData()
|
private void |
streamFile(PostEntry postEntry)
Stream the individual file. |
(package private) void |
validateFiles()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int FAILURE_NONE
getOperationFailureCode()
. Indicates
that no failure has occurred.
public static final int FAILURE_IO_ERROR
getOperationFailureCode()
. Indicates
that some IOException was thrown during the operation.
public static final int FAILURE_HTTP_ERROR
getOperationFailureCode()
. Indicates
that an HTTP error was returned.
public static final int FAILURE_FILE_NOT_FOUND
getOperationFailureCode()
. Indicates
that the file does not exist.
private URL url
private int operationStatus
private int httpResponseCode
private String httpResponseMessage
private boolean postCancelled
private Hashtable listeners
private URLConnection connection
private BufferedOutputStream bufferedOutput
private int fileNum
private Vector postData
static final String BOUNDARY
private static int BUF_SIZ
Constructor Detail |
public MultiPartPost(URL url)
MalformedULRException
- indicates that the url is not correctly formatted.Method Detail |
public static void main(String[] args)
public String getURL()
public void setData(String contentName, String value)
setData
in interface MultiPartPostIfc
contentName
- the content name to be supplied in the post.public void setPath(String contentName, String path)
setPath
in interface MultiPartPostIfc
contentName
- the content name to be supplied in the post.path
- the path to the file.public int getHTTPResponseCode()
public int getResponseCode()
getResponseCode
in interface MultiPartPostIfc
private void setHTTPResponseCode(int code)
public String getHTTPResponseMessage()
public String getResponseString()
getResponseString
in interface MultiPartPostIfc
void setHTTPResponseMessage(String message)
public int getOperationStatus()
getOperationStatus
in interface MultiPartPostIfc
private void setOperationStatus(int newValue)
public Thread performOperation(boolean separateThread)
performOperation
in interface MultiPartPostIfc
FileNotFoundException
- thrown when file can't be found.
IOException
- This is not an expected exception, indicates a critical error.public void cancelOperation()
cancelOperation
in interface MultiPartPostIfc
public void clear() throws IOException
IOException
private void openConnection() throws ProtocolException, IOException
ProtocolException
- This is not a normal exception, indicates a critical problem.
IOException
private void connect()
private void closeOutputStream()
private void closeConnection() throws IOException
IOException
private int parseHTTPResponse() throws IOException
IOException
private void showResponse(InputStream input) throws IOException
IOException
void validateFiles() throws FileNotFoundException
FileNotFoundException
private void streamData() throws IOException
IOException
private PostEntry newPostEntry(int type, String name, String value)
private void printData(PostEntry postEntry) throws IOException
IOException
private void printFileHeader(PostEntry postEntry) throws IOException
IOException
private void streamFile(PostEntry postEntry) throws FileNotFoundException, IOException
FileNotFoundException
IOException
private String getContentType(String filename)
private String parseExtension(String path)
private void println(String s) throws IOException
IOException
public void addUploadListener(MultiPartPostListener l)
public void removeUploadListener(MultiPartPostListener l)
private void operationStatusChange(int newStatus)
private void operationProgress(String contentName, String path, int byteCount)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |