src/main/java/com/sourcesense/confluence/servlets/CMISProxyServlet.java
@SuppressWarnings({"unchecked", "ToArrayCallWithZeroLengthArrayArgument"})
  private void handleMultipartPost(PostMethod postMethodProxyRequest, HttpServletRequest httpServletRequest) throws ServletException {
    // Create a factory for disk-based file items
    DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory();
    // Set factory constraints
    diskFileItemFactory.setSizeThreshold(this.getMaxFileUploadSize());
    diskFileItemFactory.setRepository(FILE_UPLOAD_TEMP_DIRECTORY);
    // Create a new file upload handler
    ServletFileUpload servletFileUpload = new ServletFileUpload(diskFileItemFactory);
    // Parse the request
    try {
      // Get the multipart items as a list
      List<FileItem> listFileItems = (List<FileItem>) servletFileUpload.parseRequest(httpServletRequest);
      // Create a list to hold all of the parts
      List<Part> listParts = new ArrayList<Part>();
      // Iterate the multipart items list
      for (FileItem fileItemCurrent : listFileItems) {
        // If the current item is a form field, then create a string part
        if (fileItemCurrent.isFormField()) {
          StringPart stringPart = new StringPart(fileItemCurrent.getFieldName(), // The field name
              fileItemCurrent.getString() // The field value
          );
          // Add the part to the list
          listParts.add(stringPart);
        } else {
          // The item is a file upload, so we create a FilePart
          FilePart filePart = new FilePart(fileItemCurrent.getFieldName(), // The field name
              new ByteArrayPartSource(fileItemCurrent.getName(), // The uploaded file name
                  fileItemCurrent.get() // The uploaded file contents
              ));
          // Add the part to the list
          listParts.add(filePart);
        }
      }
      MultipartRequestEntity multipartRequestEntity = new MultipartRequestEntity(listParts.toArray(new Part[]{}), postMethodProxyRequest.getParams());
      postMethodProxyRequest.setRequestEntity(multipartRequestEntity);
      // The current content-type header (received from the client) IS of
      // type "multipart/form-data", but the content-type header also
      // contains the chunk boundary string of the chunks. Currently, this
      // header is using the boundary of the client request, since we
      // blindly copied all headers from the client request to the proxy
      // request. However, we are creating a new request with a new chunk
      // boundary string, so it is necessary that we re-set the
      // content-type string to reflect the new chunk boundary string
      postMethodProxyRequest.setRequestHeader(STRING_CONTENT_TYPE_HEADER_NAME, multipartRequestEntity.getContentType());
    } catch (FileUploadException fileUploadException) {
      throw new ServletException(fileUploadException);
    }
  }
/**
   * Sets up the given {@link PostMethod} to send the same multipart POST
   * data as was sent in the given {@link HttpServletRequest}
   *
   * @param postMethodProxyRequest The {@link PostMethod} that we are
   *                               configuring to send a multipart POST request
   * @param httpServletRequest     The {@link HttpServletRequest} that contains
   *                               the mutlipart POST data to be sent via the {@link PostMethod}
   * @throws javax.servlet.ServletException If something fails when uploading the content to the server
   */
Sets up the given  PostMethod to send the same multipart POST
data as was sent in the given  HttpServletRequest

@param postMethodProxyRequest The  PostMethod that we are
configuring to send a multipart POST request
@param httpServletRequest     The  HttpServletRequest that contains
the mutlipart POST data to be sent via the  PostMethod
@throws javax.servlet.ServletException If something fails when uploading the content to the server
Sets up the given PostMethod to send the same multipart POST data as was sent in the given HttpServletRequest @param postMethodProxyRequest The PostMethod that we are configuring to send a multipart POST request @param httpServletRequest The HttpServletRequest that contains the mutlipart POST data to be sent via the PostMethod @throws javax . servlet . ServletException If something fails when uploading the content to the server
@SuppressWarnings({"unchecked", "ToArrayCallWithZeroLengthArrayArgument"})
  private void handleMultipartPost(PostMethod postMethodProxyRequest, HttpServletRequest httpServletRequest) throws ServletException {
    DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory();
    diskFileItemFactory.setSizeThreshold(this.getMaxFileUploadSize());
    diskFileItemFactory.setRepository(FILE_UPLOAD_TEMP_DIRECTORY);
    ServletFileUpload servletFileUpload = new ServletFileUpload(diskFileItemFactory);
    try {
      List<FileItem> listFileItems = (List<FileItem>) servletFileUpload.parseRequest(httpServletRequest);
      List<Part> listParts = new ArrayList<Part>();
      for (FileItem fileItemCurrent : listFileItems) {
        if (fileItemCurrent.isFormField()) {
          StringPart stringPart = new StringPart(fileItemCurrent.getFieldName(), 
              fileItemCurrent.getString() 
          );
          listParts.add(stringPart);
        } else {
          FilePart filePart = new FilePart(fileItemCurrent.getFieldName(), 
              new ByteArrayPartSource(fileItemCurrent.getName(), 
                  fileItemCurrent.get() 
              ));
          listParts.add(filePart);
        }
      }
      MultipartRequestEntity multipartRequestEntity = new MultipartRequestEntity(listParts.toArray(new Part[]{}), postMethodProxyRequest.getParams());
      postMethodProxyRequest.setRequestEntity(multipartRequestEntity);
      postMethodProxyRequest.setRequestHeader(STRING_CONTENT_TYPE_HEADER_NAME, multipartRequestEntity.getContentType());
    } catch (FileUploadException fileUploadException) {
      throw new ServletException(fileUploadException);
    }
  }
@ SuppressWarnings ( { "unchecked" , "ToArrayCallWithZeroLengthArrayArgument" } ) private void handleMultipartPost ( PostMethod postMethodProxyRequest , HttpServletRequest httpServletRequest ) throws ServletException { DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory ( ) ; diskFileItemFactory . setSizeThreshold ( this . getMaxFileUploadSize ( ) ) ; diskFileItemFactory . setRepository ( FILE_UPLOAD_TEMP_DIRECTORY ) ; ServletFileUpload servletFileUpload = new ServletFileUpload ( diskFileItemFactory ) ; try { List < FileItem > listFileItems = ( List < FileItem > ) servletFileUpload . parseRequest ( httpServletRequest ) ; List < Part > listParts = new ArrayList < Part > ( ) ; for ( FileItem fileItemCurrent : listFileItems ) { if ( fileItemCurrent . isFormField ( ) ) { StringPart stringPart = new StringPart ( fileItemCurrent . getFieldName ( ) , fileItemCurrent . getString ( ) ) ; listParts . add ( stringPart ) ; } else { FilePart filePart = new FilePart ( fileItemCurrent . getFieldName ( ) , new ByteArrayPartSource ( fileItemCurrent . getName ( ) , fileItemCurrent . get ( ) ) ) ; listParts . add ( filePart ) ; } } MultipartRequestEntity multipartRequestEntity = new MultipartRequestEntity ( listParts . toArray ( new Part [ ] { } ) , postMethodProxyRequest . getParams ( ) ) ; postMethodProxyRequest . setRequestEntity ( multipartRequestEntity ) ; postMethodProxyRequest . setRequestHeader ( STRING_CONTENT_TYPE_HEADER_NAME , multipartRequestEntity . getContentType ( ) ) ; } catch ( FileUploadException fileUploadException ) { throw new ServletException ( fileUploadException ) ; } }
Sets up the given {@link PostMethod} to send the same multipart POST
 data as was sent in the given {@link HttpServletRequest}
Sets up the given { @link PostMethod } to send the same multipart POST data as was sent in the given { @link HttpServletRequest }
// Create a factory for disk-based file items
 // Set factory constraints
 // Create a new file upload handler
 // Parse the request
 // Get the multipart items as a list
 // Create a list to hold all of the parts
 // Iterate the multipart items list
 // If the current item is a form field, then create a string part
 // The field name
 // The field value
 // Add the part to the list
 // The item is a file upload, so we create a FilePart
 // The field name
 // The uploaded file name
 // The uploaded file contents
 // Add the part to the list
 // The current content-type header (received from the client) IS of
 // type "multipart/form-data", but the content-type header also
 // contains the chunk boundary string of the chunks. Currently, this
 // header is using the boundary of the client request, since we
 // blindly copied all headers from the client request to the proxy
 // request. However, we are creating a new request with a new chunk
 // boundary string, so it is necessary that we re-set the
 // content-type string to reflect the new chunk boundary string
