Esri Geoportal Server
1.2.9

com.esri.gpt.agp.multipart2
Class MultipartProvider

java.lang.Object
  extended by com.esri.gpt.framework.http.ContentBase
      extended by com.esri.gpt.framework.http.ContentProvider
          extended by com.esri.gpt.agp.multipart2.MultipartProvider

public class MultipartProvider
extends ContentProvider

Provides content for a multi-part HTTP request (outbound).


Constructor Summary
MultipartProvider()
          Default constructor.
 
Method Summary
 void add(MPart part)
          Adds a part.
 void add(String name, byte[] data, String filename, String contentType, String charset)
          Adds a part.
 void add(String name, File file, String filename, String contentType, String charset, boolean deleteAfterUpload)
          Adds a part.
 void add(String name, String data)
          Adds a part.
 void add(String name, String data, String contentType)
          Adds a part.
protected  byte[] getAsciiBytes(String value)
          Gets the US-ASCII bytes for a value
 String getBoundary()
          Gets the boundary string.
 long getContentLength()
          Gets the request body content length.
 String getContentType()
          Gets the content type.
 List<MPart> getParts()
          Gets the parts.
 boolean isRepeatable()
          True if all the parts can be written to the output stream more than once.
 void setBoundary(String boundary)
          Sets the boundary string.
 void writeRequest(HttpClientRequest request, OutputStream destination)
          Writes the content of the HTTP request body to an output stream.
 
Methods inherited from class com.esri.gpt.framework.http.ContentProvider
asBytes, ensureContentTypeEncoding, prepareForWrite
 
Methods inherited from class com.esri.gpt.framework.http.ContentBase
executeIO, executeIO, getInitialBufferlength, getLoggableContent, setInitialBufferLength
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultipartProvider

public MultipartProvider()
Default constructor.

Method Detail

getBoundary

public String getBoundary()
Gets the boundary string.

Returns:
the boundary

setBoundary

public void setBoundary(String boundary)
Sets the boundary string.

Parameters:
boundary - the boundary

getContentType

public String getContentType()
Gets the content type.

Specified by:
getContentType in class ContentProvider
Returns:
the content type

getParts

public List<MPart> getParts()
Gets the parts.

Returns:
the parts

add

public void add(MPart part)
Adds a part.

Parameters:
part - the part

add

public void add(String name,
                String data)
         throws IOException
Adds a part.

Parameters:
name - the part name
data - the data value
Throws:
IOException - if an exception occurs

add

public void add(String name,
                String data,
                String contentType)
         throws IOException
Adds a part.

Parameters:
name - the name
data - the data
contentType - the content type
Throws:
IOException - if an exception occurs

add

public void add(String name,
                byte[] data,
                String filename,
                String contentType,
                String charset)
         throws IOException
Adds a part.

Parameters:
name - the name
data - the data
filename - the file name
contentType - the content type
charset - the character set
Throws:
IOException - if an exception occurs

add

public void add(String name,
                File file,
                String filename,
                String contentType,
                String charset,
                boolean deleteAfterUpload)
         throws IOException
Adds a part.

Parameters:
name - the name
file - the file
filename - the file name
contentType - the content type
charset - the character set
deleteAfterUpload - if true then delete the file after uploading
Throws:
IOException - if an exception occurs

getAsciiBytes

protected byte[] getAsciiBytes(String value)
                        throws UnsupportedEncodingException
Gets the US-ASCII bytes for a value

Parameters:
value - the value
Returns:
the bytes
Throws:
UnsupportedEncodingException - if the encoding is unsupported

getContentLength

public long getContentLength()
Gets the request body content length.

Specified by:
getContentLength in class ContentProvider
Returns:
the request content length (in bytes, -1 if unknown);

isRepeatable

public boolean isRepeatable()
True if all the parts can be written to the output stream more than once.

Specified by:
isRepeatable in class ContentProvider
Returns:
true if repeatable

writeRequest

public void writeRequest(HttpClientRequest request,
                         OutputStream destination)
                  throws IOException
Writes the content of the HTTP request body to an output stream.

Specified by:
writeRequest in class ContentProvider
Parameters:
request - the HTTP request that is executing
destination - the output stream to which data will be written
Throws:
IOException - if an exception occurs

Esri Geoportal Server
1.2.9

Copyright 2011 Environmental Systems Research Institute. All rights reserved. Use is subject to license terms.