org.apache.cocoon.servlet.multipart
Class RejectedPart

java.lang.Object
  extended by org.apache.cocoon.servlet.multipart.Part
      extended by org.apache.cocoon.servlet.multipart.RejectedPart
All Implemented Interfaces:
Disposable

public class RejectedPart
extends Part

An upload part that was rejected because request length exceeded the maximum upload size.

Since:
2.1.8
Version:
$Id: RejectedPart.html 1304258 2012-03-23 10:09:27Z ilgrosso $

Field Summary
 int contentLength
           
 int maxContentLength
           
 
Fields inherited from class org.apache.cocoon.servlet.multipart.Part
headers
 
Constructor Summary
RejectedPart(Map headers, int partSize, int contentLength, int maxContentLength)
           
 
Method Summary
 void dispose()
          Dispose any resources held by this part, such as a file or memory buffer.
 int getContentLength()
          Get the content length of the request that cause this part to be rejected.
 String getFileName()
          Returns the filename
 InputStream getInputStream()
          Always throw an IOException as this part was rejected.
 int getMaxContentLength()
          Get the maximum allowed upload size.
 int getSize()
          Get the size of this part.
 boolean isRejected()
          Always return true
 
Methods inherited from class org.apache.cocoon.servlet.multipart.Part
copyToFile, copyToSource, disposeWithRequest, getHeaders, getMimeType, getUploadName, setDisposeWithRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

contentLength

public int contentLength

maxContentLength

public int maxContentLength
Constructor Detail

RejectedPart

public RejectedPart(Map headers,
                    int partSize,
                    int contentLength,
                    int maxContentLength)
Method Detail

getFileName

public String getFileName()
Description copied from class: Part
Returns the filename

Specified by:
getFileName in class Part

getSize

public int getSize()
Get the size of this part.

Specified by:
getSize in class Part
Returns:
the size in bytes

getMaxContentLength

public int getMaxContentLength()
Get the maximum allowed upload size. Not that this applies to the full request content length, including multipart boundaries and other form data values.

This means that an upload part can be rejected although it's individual size is (a bit) smaller than the maximum size. It is therefore advisable to use getContentLength() to build error messages rather than getSize().

Returns:
the maximum content length in bytes

getContentLength

public int getContentLength()
Get the content length of the request that cause this part to be rejected.

Returns:
the content length in bytes

getInputStream

public InputStream getInputStream()
                           throws IOException
Always throw an IOException as this part was rejected.

Specified by:
getInputStream in class Part
Throws:
IOException

isRejected

public boolean isRejected()
Always return true

Overrides:
isRejected in class Part
Returns:
true if this part was rejected

dispose

public void dispose()
Description copied from class: Part
Dispose any resources held by this part, such as a file or memory buffer.

Disposal occurs in all cases when the part is garbage collected, but calling it explicitely allows to cleanup resources more quickly.

Specified by:
dispose in interface Disposable
Specified by:
dispose in class Part


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.