Package com.eviware.soapui.model.iface

Examples of com.eviware.soapui.model.iface.Attachment


    xmlBombConfig.setAttachXmlBomb( attach );
  }

  private Attachment addAttachement( TestStep testStep )
  {
    Attachment attach = null;
    if( isAttachXmlBomb() )
    {
      WsdlRequest request = ( WsdlRequest )getRequest( testStep );

      if( currentIndex < getXmlBombList().size() )
      {
        String bomb = getXmlBombList().get( currentIndex );
        try
        {
          File bombFile = File.createTempFile( getAttachmentPrefix(), ".xml" );
          BufferedWriter writer = new BufferedWriter( new FileWriter( bombFile ) );
          writer.write( bomb );
          writer.flush();
          request.setInlineFilesEnabled( false );
          attach = request.attachFile( bombFile, false );
          attach.setContentType( "text/xml;" );
          currentIndex++ ;
        }
        catch( IOException e )
        {
          SoapUI.logError( e );
View Full Code Here


    // no multipart handling?
    if( !container.isMultipartEnabled() )
    {
      for( int c = 0; c < attachments.size(); c++ )
      {
        Attachment att = attachments.get( c );
        if( att.getAttachmentType() != Attachment.AttachmentType.CONTENT )
        {
          addSingleAttachment( mp, contentIds, att );
        }
      }
    }
    else
    {
      // first identify if any part has more than one attachments
      Map<String, List<Attachment>> attachmentsMap = new HashMap<String, List<Attachment>>();
      for( int c = 0; c < attachments.size(); c++ )
      {
        Attachment att = attachments.get( c );
        if( att.getAttachmentType() == Attachment.AttachmentType.CONTENT )
          continue;

        String partName = att.getPart();

        if( !attachmentsMap.containsKey( partName ) )
        {
          attachmentsMap.put( partName, new ArrayList<Attachment>() );
        }

        attachmentsMap.get( partName ).add( att );
      }

      // add attachments
      for( Iterator<String> i = attachmentsMap.keySet().iterator(); i.hasNext(); )
      {
        attachments = attachmentsMap.get( i.next() );
        if( attachments.size() == 1 )
        {
          Attachment att = attachments.get( 0 );
          addSingleAttachment( mp, contentIds, att );
        }
        // more than one attachment with the same part -> create multipart
        // attachment
        else if( attachments.size() > 1 )
View Full Code Here

    MimeMultipart multipart = new MimeMultipart( "mixed" );
    long totalSize = 0;

    for( int c = 0; c < attachments.size(); c++ )
    {
      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 );

    mp.addBodyPart( part );
  }
View Full Code Here

      for( XmlObject include : includes )
      {
        Element elm = ( Element )include.getDomNode();
        String href = elm.getAttribute( "href" );
        Attachment attachment = getMmSupport().getAttachmentWithContentId( "<" + href.substring( 4 ) + ">" );
        if( attachment != null )
        {
          ByteArrayOutputStream data = Tools.readAll( attachment.getInputStream(), 0 );
          byte[] byteArray = data.toByteArray();

          XmlCursor cursor = include.newCursor();
          cursor.toParent();
          XmlObject parentXmlObject = cursor.getObject();
View Full Code Here

          {
            // extract contentId
            String textContent = XmlUtils.getNodeValue( cursor.getDomNode() );
            if( StringUtils.hasContent( textContent ) )
            {
              Attachment attachment = null;
              boolean isXopAttachment = false;

              // is content a reference to a file?
              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
              {
View Full Code Here

    public Object getValueAt(int rowIndex, int columnIndex) {
        if (rowIndex > getRowCount()) {
            return null;
        }

        Attachment att = container.getAttachmentAt(rowIndex);

        switch (columnIndex) {
            case 0:
                return att.isCached() ? att.getName() : att.getUrl();
            case 1:
                return att.getContentType();
            case 2:
                return att.getSize();
            case 3:
                return att.getPart();
            case 4:
                return att.getAttachmentType();
            case 5:
                return att.getContentID();
            case 6:
                return att.isCached();
            default:
                return null;
        }
    }
View Full Code Here

                int ix = fileTable.getSelectedRow();
                if (ix == -1) {
                    return;
                }

                Attachment attachment = container.getAttachmentAt(ix);

                if (attachment.isCached()) {
                    String name = attachment.getName();
                    try {
                        name = StringUtils.createFileName(name, '-');
                        File tempFile = File.createTempFile("attachment-" + name,
                                "." + ContentTypeHandler.getExtensionForContentType(attachment.getContentType()));
                        exportAttachment(tempFile, attachment, false);
                    } catch (Exception e1) {
                        UISupport.showErrorMessage(e1);
                    }
                } else {
                    Tools.openURL(attachment.getUrl());
                }
            }
        });
    }
View Full Code Here

                && !UISupport.confirm("File " + file.getName() + " exists, overwrite?", "Export Attachment")) {
            file = UISupport.getFileDialogs().saveAs(this, "Export Attachment..");
        }

        if (file != null) {
            Attachment attachment = tableModel.getAttachmentAt(fileTable.getSelectedRow());
            try {
                exportAttachment(file, attachment, true);
            } catch (Exception e) {
                UISupport.showErrorMessage(e);
            }
View Full Code Here

        if (getAttachmentCount() > 0) {
            try {
                UISupport.setHourglassCursor();
                for (int c = 0; c < getAttachmentCount(); c++) {
                    try {
                        Attachment attachment = getAttachmentAt(c);
                        newRequest.importAttachment(attachment);
                    } catch (Exception e) {
                        SoapUI.logError(e);
                    }
                }
View Full Code Here

        addAttachment(mockResponse);
        return mockResponse;
    }

    public void addAttachment(WsdlMockResponse mockResponse) throws IOException {
        Attachment attachment = new MockFileAttachment(File.createTempFile("attach", "file"), false, mockResponse);
        mockResponse.addAttachment(attachment);
    }
View Full Code Here

TOP

Related Classes of com.eviware.soapui.model.iface.Attachment

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.