Class AbstractMultiPartRequest

java.lang.Object
org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest
All Implemented Interfaces:
MultiPartRequest
Direct Known Subclasses:
JakartaMultiPartRequest, JakartaStreamMultiPartRequest

public abstract class AbstractMultiPartRequest extends Object implements MultiPartRequest
Abstract class with some helper methods, it should be used when starting development of another implementation of MultiPartRequest
  • Field Details

    • STRUTS_MESSAGES_UPLOAD_ERROR_PARAMETER_TOO_LONG_KEY

      protected static final String STRUTS_MESSAGES_UPLOAD_ERROR_PARAMETER_TOO_LONG_KEY
      See Also:
    • BUFFER_SIZE

      public static final int BUFFER_SIZE
      Defines the internal buffer size used during streaming operations.
      See Also:
    • errors

      protected List<LocalizedMessage> errors
      Internal list of raised errors to be passed to the the Struts2 framework.
    • maxSize

      protected Long maxSize
      Specifies the maximum size of the entire request.
    • maxFiles

      protected Long maxFiles
      Specifies the maximum number of files in one request.
    • maxStringLength

      protected Long maxStringLength
      Specifies the maximum length of a string parameter in a multipart request.
    • maxFileSize

      protected Long maxFileSize
      Specifies the maximum size per file in the request.
    • bufferSize

      protected int bufferSize
      Specifies the buffer size to use during streaming.
    • defaultEncoding

      protected String defaultEncoding
    • defaultLocale

      protected Locale defaultLocale
      Localization to be used regarding errors.
  • Constructor Details

    • AbstractMultiPartRequest

      public AbstractMultiPartRequest()
  • Method Details

    • setBufferSize

      public void setBufferSize(String bufferSize)
      Parameters:
      bufferSize - Sets the buffer size to be used.
    • setDefaultEncoding

      public void setDefaultEncoding(String enc)
    • setMaxSize

      public void setMaxSize(String maxSize)
      Parameters:
      maxSize - Injects the Struts multipart request maximum size.
    • setMaxFiles

      public void setMaxFiles(String maxFiles)
    • setMaxFileSize

      public void setMaxFileSize(String maxFileSize)
    • setMaxStringLength

      public void setMaxStringLength(String maxStringLength)
    • setLocaleProviderFactory

      public void setLocaleProviderFactory(LocaleProviderFactory localeProviderFactory)
    • setLocale

      protected void setLocale(jakarta.servlet.http.HttpServletRequest request)
      Parameters:
      request - Inspect the servlet request and set the locale if one wasn't provided by the Struts2 framework.
    • buildErrorMessage

      protected LocalizedMessage buildErrorMessage(Throwable e, Object[] args)
      Build error message.
      Parameters:
      e - the Throwable/Exception
      args - arguments
      Returns:
      error message
    • getErrors

      public List<LocalizedMessage> getErrors()
      Description copied from interface: MultiPartRequest
      Returns a list of error messages that may have occurred while processing the request. If there are no errors, an empty list is returned. If the underlying implementation (ie: cos, jakarta, etc) cannot support providing these errors, an empty list is also returned. This list of errors is reported back to the MultiPartRequestWrapper's errors field.
      Specified by:
      getErrors in interface MultiPartRequest
      Returns:
      a list of Strings that represent various errors during parsing
    • getCanonicalName

      protected String getCanonicalName(String originalFileName)
      Parameters:
      originalFileName - file name
      Returns:
      the canonical name based on the supplied filename