Examples of RestParamProperty


Examples of com.eviware.soapui.impl.rest.support.RestParamProperty

      public Object getValueAt( int rowIndex, int columnIndex )
      {
        if( columnIndex != columnCount )
          return super.getValueAt( rowIndex, columnIndex );
        RestParamProperty name = params.getPropertyAt( rowIndex );
        if( !locations.containsKey( name ) )
          locations.put( name, defaultLocation );
        return locations.get( name );
      }
View Full Code Here

Examples of com.eviware.soapui.impl.rest.support.RestParamProperty

      {
        if( columnIndex != columnCount )
          super.setValueAt( value, rowIndex, columnIndex );
        else
        {
          RestParamProperty name = params.getPropertyAt( rowIndex );
          locations.put( name, ( ParamLocation )value );
        }
      }
View Full Code Here

Examples of com.eviware.soapui.impl.rest.support.RestParamProperty

    RestParamsPropertyHolder params = request.getParams();

    for( int c = 0; c < params.getPropertyCount(); c++ )
    {
      RestParamProperty param = params.getPropertyAt( c );

      String value = PropertyExpander.expandProperties( context, param.getValue() );
      responseProperties.put( param.getName(), value );

      List<String> valueParts = sendEmptyParameters( request ) ? RestUtils.splitMultipleParametersEmptyIncluded(
          value, request.getMultiValueDelimiter() ) : RestUtils.splitMultipleParameters( value,
          request.getMultiValueDelimiter() );

      // skip HEADER and TEMPLATE parameter encoding (TEMPLATE is encoded by
      // the URI handling further down)
      if( value != null && param.getStyle() != ParameterStyle.HEADER && param.getStyle() != ParameterStyle.TEMPLATE
          && !param.isDisableUrlEncoding() )
      {
        try
        {
          String encoding = System.getProperty( "soapui.request.encoding", request.getEncoding() );

          if( StringUtils.hasContent( encoding ) )
          {
            value = URLEncoder.encode( value, encoding );
            for( int i = 0; i < valueParts.size(); i++ )
              valueParts.set( i, URLEncoder.encode( valueParts.get( i ), encoding ) );
          }
          else
          {
            value = URLEncoder.encode( value );
            for( int i = 0; i < valueParts.size(); i++ )
              valueParts.set( i, URLEncoder.encode( valueParts.get( i ) ) );
          }
        }
        catch( UnsupportedEncodingException e1 )
        {
          SoapUI.logError( e1 );
          value = URLEncoder.encode( value );
          for( int i = 0; i < valueParts.size(); i++ )
            valueParts.set( i, URLEncoder.encode( valueParts.get( i ) ) );
        }
        // URLEncoder replaces space with "+", but we want "%20".
        value = value.replaceAll( "\\+", "%20" );
        for( int i = 0; i < valueParts.size(); i++ )
          valueParts.set( i, valueParts.get( i ).replaceAll( "\\+", "%20" ) );
      }

      if( !sendEmptyParameters( request ) )
      {
        if( !StringUtils.hasContent( value ) && !param.getRequired() )
          continue;
      }

      switch( param.getStyle() )
      {
      case HEADER :
        for( String valuePart : valueParts )
          httpMethod.addRequestHeader( param.getName(), valuePart );
        break;
      case QUERY :
        if( formMp == null || !request.isPostQueryString() )
        {
          for( String valuePart : valueParts )
          {
            if( query.length() > 0 )
              query.append( '&' );

            query.append( URLEncoder.encode( param.getName() ) );
            query.append( '=' );
            if( StringUtils.hasContent( valuePart ) )
              query.append( valuePart );
          }
        }
        else
        {
          try
          {
            addFormMultipart( request, formMp, param.getName(), responseProperties.get( param.getName() ) );
          }
          catch( MessagingException e )
          {
            e.printStackTrace();
          }
        }

        break;
      case TEMPLATE :
        path = path.replaceAll( "\\{" + param.getName() + "\\}", value == null ? "" : value );
        break;
      case MATRIX :
        if( param.getType().equals( XmlBoolean.type.getName() ) )
        {
          if( value.toUpperCase().equals( "TRUE" ) || value.equals( "1" ) )
          {
            path += ";" + param.getName();
          }
        }
        else
        {
          path += ";" + param.getName();
          if( StringUtils.hasContent( value ) )
          {
            path += "=" + value;
          }
        }
View Full Code Here

Examples of com.eviware.soapui.impl.rest.support.RestParamProperty

                && httpMethod instanceof HttpEntityEnclosingRequestBase ? new MimeMultipart() : null;

        RestParamsPropertyHolder params = request.getParams();

        for (int c = 0; c < params.getPropertyCount(); c++) {
            RestParamProperty param = params.getPropertyAt(c);

            String value = PropertyExpander.expandProperties(context, param.getValue());
            responseProperties.put(param.getName(), value);

            List<String> valueParts = sendEmptyParameters(request)
                    || (!StringUtils.hasContent(value) && param.getRequired()) ? RestUtils
                    .splitMultipleParametersEmptyIncluded(value, request.getMultiValueDelimiter()) : RestUtils
                    .splitMultipleParameters(value, request.getMultiValueDelimiter());

            // skip HEADER and TEMPLATE parameter encoding (TEMPLATE is encoded by
            // the URI handling further down)
            if (value != null && param.getStyle() != ParameterStyle.HEADER && param.getStyle() != ParameterStyle.TEMPLATE
                    && !param.isDisableUrlEncoding()) {
                try {
                    if (StringUtils.hasContent(encoding)) {
                        value = URLEncoder.encode(value, encoding);
                        for (int i = 0; i < valueParts.size(); i++) {
                            valueParts.set(i, URLEncoder.encode(valueParts.get(i), encoding));
                        }
                    } else {
                        value = urlEncodeWithUtf8(value);
                        for (int i = 0; i < valueParts.size(); i++) {
                            valueParts.set(i, urlEncodeWithUtf8(valueParts.get(i)));
                        }
                    }
                } catch (UnsupportedEncodingException e1) {
                    SoapUI.logError(e1);
                    value = urlEncodeWithUtf8(value);
                    for (int i = 0; i < valueParts.size(); i++) {
                        valueParts.set(i, urlEncodeWithUtf8(valueParts.get(i)));
                    }
                }
                // URLEncoder replaces space with "+", but we want "%20".
                value = value.replaceAll("\\+", "%20");
                for (int i = 0; i < valueParts.size(); i++) {
                    valueParts.set(i, valueParts.get(i).replaceAll("\\+", "%20"));
                }
            }

            if (param.getStyle() == ParameterStyle.QUERY && !sendEmptyParameters(request)) {
                if (!StringUtils.hasContent(value) && !param.getRequired()) {
                    continue;
                }
            }

            switch (param.getStyle()) {
                case HEADER:
                    for (String valuePart : valueParts) {
                        httpMethod.addHeader(param.getName(), valuePart);
                    }
                    break;
                case QUERY:
                    if (formMp == null || !request.isPostQueryString()) {
                        for (String valuePart : valueParts) {
                            if (query.length() > 0) {
                                query.append('&');
                            }

                            query.append(urlEncodeWithUtf8(param.getName()));
                            query.append('=');
                            if (StringUtils.hasContent(valuePart)) {
                                query.append(valuePart);
                            }
                        }
                    } else {
                        try {
                            addFormMultipart(request, formMp, param.getName(), responseProperties.get(param.getName()));
                        } catch (MessagingException e) {
                            SoapUI.logError(e);
                        }
                    }

                    break;
                case TEMPLATE:
                    try {
                        value = getEncodedValue(value, encoding, param.isDisableUrlEncoding(), request
                                .getSettings().getBoolean(HttpSettings.ENCODED_URLS));
                        path = path.replaceAll("\\{" + param.getName() + "\\}", value == null ? "" : value);
                    } catch (UnsupportedEncodingException e) {
                        SoapUI.logError(e);
                    }
                    break;
                case MATRIX:
                    try {
                        value = getEncodedValue(value, encoding, param.isDisableUrlEncoding(), request
                                .getSettings().getBoolean(HttpSettings.ENCODED_URLS));
                    } catch (UnsupportedEncodingException e) {
                        SoapUI.logError(e);
                    }

                    if (param.getType().equals(XmlBoolean.type.getName())) {
                        if (value.toUpperCase().equals("TRUE") || value.equals("1")) {
                            path += ";" + param.getName();
                        }
                    } else {
                        path += ";" + param.getName();
                        if (StringUtils.hasContent(value)) {
                            path += "=" + value;
                        }
                    }
                    break;
View Full Code Here

Examples of com.eviware.soapui.impl.rest.support.RestParamProperty

    }

    //TODO: In advanced version we have to apply filtering like which type of parameter goes to which location
    protected void copyParameters(RestParamsPropertyHolder srcParams, RestParamsPropertyHolder destinationParams) {
        for (int i = 0; i < srcParams.size(); i++) {
            RestParamProperty prop = srcParams.getPropertyAt(i);

            destinationParams.addParameter(prop);

        }
    }
View Full Code Here

Examples of com.eviware.soapui.impl.rest.support.RestParamProperty

    }

    //TODO: In advanced version we have to apply filtering like which type of parameter goes to which location
    protected void copyParametersWithDefaultsOnResource(RestParamsPropertyHolder srcParams, RestParamsPropertyHolder resourceParams, RestParamsPropertyHolder requestParams) {
        for (int i = 0; i < srcParams.size(); i++) {
            RestParamProperty prop = srcParams.getPropertyAt(i);
            String value = prop.getValue();
            prop.setValue("");
            prop.setDefaultValue("");
            resourceParams.addParameter(prop);

            requestParams.getProperty(prop.getName()).setValue(value);
        }
    }
View Full Code Here

Examples of com.eviware.soapui.impl.rest.support.RestParamProperty

            public int getColumnCount() {
                return 2;
            }

            public Object getValueAt(int rowIndex, int columnIndex) {
                RestParamProperty prop = params.getPropertyAt(rowIndex);
                return columnIndex == 0 ? prop.getName() : prop.getValue();
            }

            @Override
            public void setValueAt(Object value, int rowIndex, int columnIndex) {
                RestParamProperty prop = params.getPropertyAt(rowIndex);
                if (columnIndex == 0) {
                    prop.setName(value.toString());
                } else {
                    prop.setValue(value.toString());
                }
            }
        };
        return new RestParamsTable(httpRequest.getParams(), false, restParamsTableModel, ParamLocation.RESOURCE, true, false);
    }
View Full Code Here

Examples of com.eviware.soapui.impl.rest.support.RestParamProperty

        return matcherToReturn;
    }

    @Override
    public boolean matchesSafely(RestParamsPropertyHolder restParameters) {
        RestParamProperty property = restParameters.getProperty(parameterName);
        return property != null && (parameterValue == null || parameterValue.equals(parameterValue));
    }
View Full Code Here

Examples of com.eviware.soapui.impl.rest.support.RestParamProperty

                break;
        }

        if (paramsPropertyHolder != null) {
            paramsPropertyHolder.addProperty(name);
            RestParamProperty addedParameter = paramsPropertyHolder.getProperty(name);
            addedParameter.addPropertyChangeListener(restParamPropertyChangeListener);
            addedParameter.setValue(value);
            addedParameter.setDefaultValue(value);
            addedParameter.setStyle(style);
            //Override the request level value as well
            getRequest().getParams().getProperty(name).setValue(requestLevelValue);
        }
        addPropertyChangeListenerToResource(getRequest());
    }
View Full Code Here

Examples of com.eviware.soapui.impl.rest.support.RestParamProperty

        }

        @Override
        public void propertyAdded(String name) {
            updateUiValues();
            RestParamProperty property = getRequest().getParams().getProperty(name);
            property.addPropertyChangeListener(restParamPropertyChangeListener);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.