Package com.eviware.soapui.model.iface

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


          {
            for( int c = 0; c < attachments.length; c++ )
            {
              fileName = nameBase + "-attachment-" + ( c + 1 ) + ".";

              Attachment attachment = attachments[c];
              String contentType = attachment.getContentType();
              if( !"application/octet-stream".equals( contentType ) && contentType != null
                  && contentType.indexOf( '/' ) != -1 )
              {
                fileName += contentType.substring( contentType.lastIndexOf( '/' ) + 1 );
              }
              else
              {
                fileName += "dat";
              }

              fileName = absoluteOutputFolder + File.separator + fileName;

              FileOutputStream outFile = new FileOutputStream( fileName );
              Tools.writeAll( outFile, attachment.getInputStream() );
              outFile.close();
            }
          }
        }
View Full Code Here


        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

          {
            for( int c = 0; c < attachments.length; c++ )
            {
              fileName = nameBase + "-attachment-" + ( c + 1 ) + ".";

              Attachment attachment = attachments[c];
              String contentType = attachment.getContentType();
              if( !"application/octet-stream".equals( contentType ) && contentType != null
                  && contentType.indexOf( '/' ) != -1 )
              {
                fileName += contentType.substring( contentType.lastIndexOf( '/' ) + 1 );
              }
              else
              {
                fileName += "dat";
              }

              fileName = absoluteOutputFolder + File.separator + fileName;

              FileOutputStream outFile = new FileOutputStream( fileName );
              Tools.writeAll( outFile, attachment.getInputStream() );
              outFile.close();
            }
          }
        }
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

      file = UISupport.getFileDialogs().saveAs( this, "Export Attachment.." );
    }

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

      {
        errors.add( XmlError.forMessage( "Missing attachment for part [" + part.getName() + "]" ) );
      }
      else if( attachments.length == 1 )
      {
        Attachment attachment = attachments[0];
        String types = "";
        for( MIMEContent content : contents )
        {
          String type = content.getType();
          if( type.equals( attachment.getContentType() ) || type.toUpperCase().startsWith( "MULTIPART" ) )
          {
            types = null;
            break;
          }
          if( types.length() > 0 )
            types += ",";

          types += type;
        }

        if( types != null )
        {
          String msg = "Missing attachment for part [" + part.getName() + "] with content-type [" + types + "],"
              + " content type is [" + attachment.getContentType() + "]";

          if( SoapUI.getSettings().getBoolean( WsdlSettings.ALLOW_INCORRECT_CONTENTTYPE ) )
            log.warn( msg );
          else
            errors.add( XmlError.forMessage( msg ) );
View Full Code Here

      {
        errors.add( XmlError.forMessage( "Missing attachment for part [" + part.getName() + "]" ) );
      }
      else if( attachments.length == 1 )
      {
        Attachment attachment = attachments[0];
        String types = "";
        for( MIMEContent content : contents )
        {
          String type = content.getType();
          if( type.equals( attachment.getContentType() ) || type.toUpperCase().startsWith( "MULTIPART" ) )
          {
            types = null;
            break;
          }

          if( types.length() > 0 )
            types += ",";

          types += type;
        }

        if( types != null )
        {
          String msg = "Missing attachment for part [" + part.getName() + "] with content-type [" + types
              + "], content type is [" + attachment.getContentType() + "]";

          if( SoapUI.getSettings().getBoolean( WsdlSettings.ALLOW_INCORRECT_CONTENTTYPE ) )
            log.warn( msg );
          else
            errors.add( XmlError.forMessage( msg ) );
View Full Code Here

  private Attachment addAttachment( TestStep testStep, File file, String contentType, boolean generated, boolean cache )
      throws IOException
  {
    AbstractHttpRequest<?> request = ( AbstractHttpRequest<?> )getRequest( testStep );
    Attachment attach = request.attachFile( file, cache );
    attach.setContentType( contentType );

    return attach;
  }
View Full Code Here

    {
      if( evt.getOldValue() == null && evt.getNewValue() != null )
      {
        if( evt.getNewValue() instanceof Attachment )
        {
          Attachment attachment = ( Attachment )evt.getNewValue();
          addedAttachment( attachment );
        }
      }
      else if( evt.getOldValue() != null && evt.getNewValue() == null )
      {
        if( evt.getOldValue() instanceof Attachment )
        {
          Attachment attachment = ( Attachment )evt.getOldValue();
          removedAttachment( 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.