Package javax.mail.internet

Examples of javax.mail.internet.PreencodedMimeBodyPart


          }
        }

        for( Attachment attachment : request.getAttachments() )
        {
          MimeBodyPart part = new PreencodedMimeBodyPart( "binary" );

          if( attachment instanceof FileAttachment<?> )
          {
            String name = attachment.getName();
            if( StringUtils.hasContent( attachment.getContentID() ) && !name.equals( attachment.getContentID() ) )
              name = attachment.getContentID();

            part.setDisposition( "form-data; name=\"" + name + "\"; filename=\"" + attachment.getName() + "\"" );
          }
          else
            part.setDisposition( "form-data; name=\"" + attachment.getName() + "\"" );

          part.setDataHandler( new DataHandler( new AttachmentDataSource( attachment ) ) );

          formMp.addBodyPart( part );
        }

        MimeMessage message = new MimeMessage( AttachmentUtils.JAVAMAIL_SESSION );
View Full Code Here


  }

  protected void initRootPart( HttpRequestInterface<?> wsdlRequest, String requestContent, MimeMultipart mp )
      throws MessagingException
  {
    MimeBodyPart rootPart = new PreencodedMimeBodyPart( "8bit" );
    // rootPart.setContentID( AttachmentUtils.ROOTPART_SOAPUI_ORG );
    mp.addBodyPart( rootPart, 0 );

    DataHandler dataHandler = new DataHandler( new RestRequestDataSource( wsdlRequest, requestContent ) );
    rootPart.setDataHandler( dataHandler );
  }
View Full Code Here

    return responseContent;
  }

  private void initRootPart( String requestContent, MimeMultipart mp, boolean isXOP ) throws MessagingException
  {
    MimeBodyPart rootPart = new PreencodedMimeBodyPart( "8bit" );
    rootPart.setContentID( AttachmentUtils.ROOTPART_SOAPUI_ORG );
    mp.addBodyPart( rootPart, 0 );

    DataHandler dataHandler = new DataHandler( new MockResponseDataSource( this, requestContent, isXOP ) );
    rootPart.setDataHandler( dataHandler );
  }
View Full Code Here

              if( container.isInlineFilesEnabled() && textContent.startsWith( "file:" ) )
              {
                String filename = textContent.substring( 5 );
                if( container.isMtomEnabled() )
                {
                  MimeBodyPart part = new PreencodedMimeBodyPart( "binary" );
                  String xmimeContentType = getXmlMimeContentType( cursor );

                  if( StringUtils.isNullOrEmpty( xmimeContentType ) )
                    xmimeContentType = ContentTypeHandler.getContentTypeFromFilename( filename );

                  part.setDataHandler( new DataHandler( new XOPPartDataSource( new File( filename ),
                      xmimeContentType, schemaType ) ) );
                  part.setContentID( "<" + filename + ">" );
                  mp.addBodyPart( part );

                  isXopAttachment = true;
                }
                else
                {
                  if( new File( filename ).exists() )
                  {
                    inlineData( cursor, schemaType, new FileInputStream( filename ) );
                  }
                  else
                  {
                    Attachment att = getAttachmentForFilename( container, filename );
                    if( att != null )
                      inlineData( cursor, schemaType, att.getInputStream() );
                  }
                }
              }
              else
              {
                Attachment[] attachmentsForPart = container.getAttachmentsForPart( textContent );
                if( textContent.startsWith( "cid:" ) )
                {
                  textContent = textContent.substring( 4 );
                  attachmentsForPart = container.getAttachmentsForPart( textContent );

                  Attachment[] attachments = attachmentsForPart;
                  if( attachments.length == 1 )
                  {
                    attachment = attachments[0];
                  }
                  else if( attachments.length > 1 )
                  {
                    attachment = buildMulitpartAttachment( attachments );
                  }

                  isXopAttachment = container.isMtomEnabled();
                  contentIds.put( textContent, textContent );
                }
                // content should be binary data; is this an XOP element
                // which should be serialized with MTOM?
                else if( container.isMtomEnabled()
                    && ( SchemaUtils.isBinaryType( schemaType ) || SchemaUtils.isAnyType( schemaType ) ) )
                {
                  if( "true".equals( System.getProperty( "soapui.mtom.strict" ) ) )
                  {
                    if( SchemaUtils.isAnyType( schemaType ) )
                    {
                      textContent = null;
                    }
                    else
                    {
                      for( int c = 0; c < textContent.length(); c++ )
                      {
                        if( Character.isWhitespace( textContent.charAt( c ) ) )
                        {
                          textContent = null;
                          break;
                        }
                      }
                    }
                  }

                  if( textContent != null )
                  {
                    MimeBodyPart part = new PreencodedMimeBodyPart( "binary" );
                    String xmimeContentType = getXmlMimeContentType( cursor );

                    part.setDataHandler( new DataHandler( new XOPPartDataSource( textContent,
                        xmimeContentType, schemaType ) ) );

                    textContent = "http://www.soapui.org/" + System.nanoTime();

                    part.setContentID( "<" + textContent + ">" );
                    mp.addBodyPart( part );

                    isXopAttachment = true;
                  }
                }
View Full Code Here

    {
      Attachment att = attachments.get( c );
      String contentType = att.getContentType();
      totalSize += att.getSize();

      MimeBodyPart part = contentType.startsWith( "text/" ) ? new MimeBodyPart() : new PreencodedMimeBodyPart(
          "binary" );

      part.setDataHandler( new DataHandler( new AttachmentDataSource( att ) ) );
      initPartContentId( contentIds, part, att, false );
      multipart.addBodyPart( part );
    }

    MimeBodyPart part = new PreencodedMimeBodyPart( "binary" );

    if( totalSize > MAX_SIZE_IN_MEMORY_ATTACHMENT )
    {
      part.setDataHandler( new DataHandler( new MultipartAttachmentFileDataSource( multipart ) ) );
    }
    else
    {
      part.setDataHandler( new DataHandler( new MultipartAttachmentDataSource( multipart ) ) );
    }

    Attachment attachment = attachments.get( 0 );
    initPartContentId( contentIds, part, attachment, true );
View Full Code Here

  public static void addSingleAttachment( MimeMultipart mp, StringToStringMap contentIds, Attachment att )
      throws MessagingException
  {
    String contentType = att.getContentType();
    MimeBodyPart part = contentType.startsWith( "text/" ) ? new MimeBodyPart()
        : new PreencodedMimeBodyPart( "binary" );

    part.setDataHandler( new DataHandler( new AttachmentDataSource( att ) ) );
    initPartContentId( contentIds, part, att, false );

    mp.addBodyPart( part );
View Full Code Here

                        initRootPart(request, requestContent, formMp);
                    }
                }

                for (Attachment attachment : request.getAttachments()) {
                    MimeBodyPart part = new PreencodedMimeBodyPart("binary");

                    if (attachment instanceof FileAttachment<?>) {
                        String name = attachment.getName();
                        if (StringUtils.hasContent(attachment.getContentID()) && !name.equals(attachment.getContentID())) {
                            name = attachment.getContentID();
                        }

                        part.setDisposition("form-data; name=\"" + name + "\"; filename=\"" + attachment.getName() + "\"");
                    } else {
                        part.setDisposition("form-data; name=\"" + attachment.getName() + "\"");
                    }

                    part.setDataHandler(new DataHandler(new AttachmentDataSource(attachment)));

                    formMp.addBodyPart(part);
                }

                MimeMessage message = new MimeMessage(AttachmentUtils.JAVAMAIL_SESSION);
View Full Code Here

        formMp.addBodyPart(part);
    }

    protected void initRootPart(HttpRequestInterface<?> wsdlRequest, String requestContent, MimeMultipart mp)
            throws MessagingException {
        MimeBodyPart rootPart = new PreencodedMimeBodyPart("8bit");
        // rootPart.setContentID( AttachmentUtils.ROOTPART_SOAPUI_ORG );
        mp.addBodyPart(rootPart, 0);

        DataHandler dataHandler = new DataHandler(new RestRequestDataSource(wsdlRequest, requestContent));
        rootPart.setDataHandler(dataHandler);
    }
View Full Code Here

     * Creates root BodyPart containing message
     */

    protected void initRootPart(WsdlRequest wsdlRequest, String requestContent, MimeMultipart mp, boolean isXOP)
            throws MessagingException {
        MimeBodyPart rootPart = new PreencodedMimeBodyPart(System.getProperty("soapui.bodypart.encoding", "8bit"));
        rootPart.setContentID(AttachmentUtils.ROOTPART_SOAPUI_ORG);
        mp.addBodyPart(rootPart, 0);

        DataHandler dataHandler = new DataHandler(new WsdlRequestDataSource(wsdlRequest, requestContent, isXOP));
        rootPart.setDataHandler(dataHandler);
    }
View Full Code Here

    public MessageXmlObject createMessageXmlObject(String responseContent, WsdlOperation wsdlOperation) {
        return new MessageXmlObject(wsdlOperation, responseContent, false);
    }

    private void initRootPart(String requestContent, MimeMultipart mp, boolean isXOP) throws MessagingException {
        MimeBodyPart rootPart = new PreencodedMimeBodyPart("8bit");
        rootPart.setContentID(AttachmentUtils.ROOTPART_SOAPUI_ORG);
        mp.addBodyPart(rootPart, 0);

        DataHandler dataHandler = new DataHandler(new MockResponseDataSource(this, requestContent, isXOP));
        rootPart.setDataHandler(dataHandler);
    }
View Full Code Here

TOP

Related Classes of javax.mail.internet.PreencodedMimeBodyPart

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.